'How do I automatically number images in html using R Markdown?

I am using R Markdown to create a long html document with multiple images inserted throughout. I need automatically numbered figure captions, but cannot figure out how to generate them.

I insert figures this way:

![An informative figure caption](path.png)

The YAML metadata looks like this:

title: "My Title"
author: "me"
bibliography: References.bibtex
output: 
  bookdown::html_document2:
  number_sections: TRUE
  fig_caption: TRUE


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source