How to add image from within 'content' subfolder - pelican

816 Views Asked by At

I got a structure

content/
├── applications
│   └── 2017
│       └── 08
│           └── 30
│               ├── article.md
│               └── forecast1.png

I want the img files to be same directories as the md files so that they can be put to:

ARTICLE_SAVE_AS = 'posts/{date:%Y}/{date:%b}/{date:%d}/{slug}/index.html' 

I have STATIC_PATHS = ['static_files','content'] however, the

[alt]({attach}applications/2017/08/30/forecast1.png)

gives error:

WARNING: Unable to find `applications/2017/08/30/forecast1.png`, skipping url replacement.

How can I include image into my md file in this simple case?

EDIT so I changed the config applications is my category to:

PATH = 'content'
STATIC_PATHS = ['static_files','applications/2017/08/30/img', 'applications/2017/09/01/img']
ARTICLE_PATHS = ['applications', 'cat2', 'cat3']

I also added the ! before the [alt]() and still the images are not copied over to output.

EDIT2 iT WORKS WHEN APPLY EDIT ABOVE AND CHANGE ({attach}img/forecast1.png)

1

There are 1 best solutions below

3
On BEST ANSWER

This works for me (following this):

content/
├── p001
│   └── myArticle001.md
│   └── img001
│       └── myPic1.png
│       └── myPic2.png
├── p002
│   └── myArticle002.md
│   └── img002
│       └── myPic1.png
│       └── myPic2.png

In pelicanconfig.py set:

PATH = 'content'
STATIC_PATHS = ['p001','p002']
ARTICLE_PATHS = STATIC_PATHS

In the md-files set:

![pic_A1]({attach}img001/myPic1.png)
![pic_A2]({attach}img001/myPic2.png)

and

![pic_B1]({attach}img002/myPic1.png)
![pic_B2]({attach}img002/myPic2.png)

Probabley you missed a ! only at the begin of the command. So you might try this:

![alt]({attach}applications/2017/08/30/forecast1.png)

Or try this:

PATH = 'content'
STATIC_PATHS = ['applications']
ARTICLE_PATHS = STATIC_PATHS
...
![alt]({attach}2017/08/30/forecast1.png)