I have created a layout for my posts, but it gets confused since I’m trying to access some media I got outside the _layouts, _includes, _etc. folders.
How can I reference them in a decent way?
I have created a layout for my posts, but it gets confused since I’m trying to access some media I got outside the _layouts, _includes, _etc. folders.
How can I reference them in a decent way?
What is an example of how you are doing it now?
not sure I follow, but can’t you just use the fuil path to them?
/assets/post-images/myimage.jpg?
Given your assets are in your source directory, the standard way of referencing assets looks like:
{{ "/assets/images/a-picture.jpg" | relative_url }}
Thank you for the replies.
I solved it having a permalink for each post.
It is recommended to use assets
folder for that purpose. There you can keep images, stylesheets, scripts, fonts, SVGs and whatnot.
To reference those you can use what @Frank has suggested or try jekyll-assets (2.4.0)
plugin (which I would recommend the best). This is how I reference assets using the plugin in one of my projects (https://staticpages.io):
<!-- STYLE -->
{% stylesheet "font-awesome.min" %}
{% stylesheet "bootstrap" %}
...
<!-- jQuery library -->
{% javascript "jquery.min" %}
<!-- jQuery validation plugin -->
{% javascript "jquery.validate.min" %}
...
Here you can read a bit more about built-in assets support in Jekyll:
https://jekyllrb.com/docs/assets/
And here you can find more about jekyll-assets
plugin: https://github.com/jekyll/jekyll-assets
Hope that helps!