I am trying to attach an image in Pelican, following the documentation here. Here is the markdown:
![energy]({filename}images/energy.png)
and the pelicanconf.py:
PATH = 'content'
STATIC_PATHS = ['images', 'pdfs']
ARTICLE_URL = 'blog/{date:%Y}/{date:%m}/{slug}.html'
ARTICLE_SAVE_AS = 'blog/{date:%Y}/{date:%m}/{slug}.html'
The .html
files are written into output/YYYY/MM/
directory where the markdown gets interpreted as:
<img alt="energy" src="{filename}/images/energy.png"/>
in the .html
while the images are written into output/images
folder.
So the HTML files cannot find the images. How do I fix it? Ideally, I would like to store the images in the same folder as the .html
files (I think that is what {attach}
does).
Any help would be appreciated.
Make sure you are using {attach}
and not {filename}
.
Also, if you have energy.png
in the same folder as blogpost.md
then {attach} will work. With your example you must have energy.png
in the images subfolder.
The documentation states that you should be careful of images being attached to multiple pages. If energy.png
is only being {attached}
-ed to blogpost.md
then it will get published alongside the resulting HTML file. Otherwise it may be moved to a place were otherblogpost.md
won't expect it to be, unless all files are in the same directory, which is not going to happen in your case (where the resulting html files are in the date subfolders).
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