While I am looking the doc. I saw the following document structure,
.
├── _config.yml
├── _drafts
| ├── begin-with-the-crazy-ideas.textile
| └── on-simplicity-in-technology.markdown
├── _includes
| ├── footer.html
| └── header.html
├── _layouts
| ├── default.html
| └── post.html
├── _posts
| ├── 2007-10-29-why-every-programmer-should-play-nethack.textile
| └── 2009-04-26-barcamp-boston-4-roundup.textile
├── _data
| └── members.yml
├── _site
├── .jekyll-metadata
└── index.html
When I need to include an image inside my post. Where should I put the image to use the feature of site.static_files
mentioned here (Static Files Section in the Documentation)? So that I can use variable like file.path
and file.modified_time
directly.
Previously when I was using Jekyll 2.x, I was doing something like below by creating my own asset directory.
<link rel="stylesheet" href="{{ "/assets/css/index.css" | prepend: site.url }}">
Assuming you have your gallery images in a structure like
-img
-gallery
-image1.png
-image2.png
etc.
you can access them in a collection or page like this:
{% for image in site.static_files %}
{% if image.path contains 'img/gallery' %}
<p>{{image.path}} - {{image.modified_time}}</p>
<img src="{{site.baseurl}}{{image.path}}">
{% endif %}
{% endfor %}
This goes through all static files and check for a certain path (img/gallery
in this example).
Than you can access the static file metadata for that file. (I named it 'image' in this example but you can name it whatever you want after the for
keyword).
I think it doesn't make too much sense to put something like this in a blog post but rather in a page
or a collection
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With