How to achieve the same behaviour than archives or pages in content folder with Pelican?

Viewed 83

I would like that in the same way Pelican generates content using pages or articles folder and these is structured as page as file under /pages/ path I would like how to do the same if I want for example have the same behavior with for example other folder called products in order to Pelican generate /products/<file>.hml.

content
   products
       product1.md
       product2.md
   articles
       article1.md
       article2.md
   pages
       about.md
       index.md

It should be easy (I think) to say Pelican that I want to process another folder inside content as it does, but I don't find the way.

Any idea? Maybe some Pelican plugin?

I've seen this answer: Python Pelican: How can I separate content by category? but is not exactly that Ï want because he is talking about subfolders inside pages folder.

Thanks!

1 Answers

After messing with the available options, it seems that the path of least resistance in your scenario would be to set PATH_METADATA in your configuration file. Here is what you can have concretely:

# In pelicanconf.py
PATH_METADATA= '(?P<path_no_ext>.*)\..*'
ARTICLE_URL = '{path_no_ext}.html'
ARTICLE_SAVE_AS = '{path_no_ext}.html'

This will recreate the structure of content inside your output directory like so:

. (output folder)
├── about.html
├── archives.html
├── index.html
├── etc.
├── products
│   └── article-filename.html
│   └── article2-filename.html
├── articles
│   ├── article3-filename.html
│   └── article4-filename.html
├── pages
│   ├── article5-filename.html
│   └── article6-filename.html
Related