There are two semantically correct solutions to this issue:
- Using the plugin
- Create custom inclusion
1. Using the plugin
I tried a couple of plugins doing this and my favorite is jekyll-figure .
1.1. Install jekyll-figure
One way to install jekyll-figure is to add the gem "jekyll-figure" to your Gemfile in the plugin group.
Then run bundle install from your terminal window.
1.2. Use jekyll-figure
Just wrap your {% endfigure %} tags {% figure %} and {% endfigure %} .
The title goes in the opening tag {% figure %} , and you can even style it with markdown!
Example:
{% figure caption:"Le logo de **Jekyll** et son clin d'oeil à Robert Louis Stevenson" %}  {% endfigure %}
1.3. Style is
Now that your images and captions are semantically correct, you can apply CSS the way you want:
figure (for image and caption)figure img (image only)figcaption (for signature only)
2. Creating a custom inclusion
You need to create an image.html file in the _includes folder, and enable it using the liquid in Markdown.
2.1. Create _includes / image.html
Create an image.html document in the _includes folder:
<figure> {% if include.url %} <a href="{{ include.url }}"> {% endif %} <img {% if include.srcabs %} src="{{ include.srcabs }}" {% else %} src="{{ site.baseurl }}/assets/images/{{ include.src }}" {% endif %} alt="{{ include.alt }}"> {% if include.url %} </a> {% endif %} {% if include.caption %} <figcaption>{{ include.caption }}</figcaption> {% endif %} </figure>
2.2. In Markdown, add an image using Liquid
Image in /assets/images with caption:
This is [Jekyll](https://jekyllrb.com) logo : {% include image.html src="jekyll-logo.png" alt="Jekyll logo" caption="This is Jekyll logo, featuring Dr. Jekyll serum!" %}
(External) image using an absolute URL: (change src="" to srcabs="" )
This is [Jekyll](https://jekyllrb.com) logo : {% include image.html srcabs="https://jekyllrb.com/img/logo-2x.png" alt="Jekyll logo" caption="This is Jekyll logo, featuring Dr. Jekyll serum!" %}
Clickable Image: (add url="" argument)
This is [Jekyll](https://jekyllrb.com) logo : {% include image.html src="https://jekyllrb.com/img/logo-2x.png" url="https://jekyllrb.com" alt="Jekyll logo" caption="This is Jekyll logo, featuring Dr. Jekyll serum!" %}
Image without signature:
This is [Jekyll](https://jekyllrb.com) logo : {% include image.html src="https://jekyllrb.com/img/logo-2x.png" alt="Jekyll logo" %}
2.3. Style is
Now that your images and captions are semantically correct, you can apply CSS the way you want:
figure (for image and caption)figure img (image only)figcaption (for signature only)