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

和自甴很熟 提交于 2019-12-11 07:28:09

问题


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:


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)


来源:https://stackoverflow.com/questions/46083594/how-to-add-image-from-within-content-subfolder-pelican

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!