Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I override the default template used by a page or article in pelican?

Tags:

python

pelican

I would like to know how can I use a different template for a page or article in pelican?

So far, it seems that for articles is using article.html and for pages page.html.

like image 504
sorin Avatar asked Aug 31 '13 17:08

sorin


2 Answers

You can set the output filename by using the Template metadata in your individual files. This will override the default that you set in your configuration file.

For Markdown you would include this in your header:

 Template: template_name

This is discussed in the FAQ on the pelican website.

like image 114
Adam Tindale Avatar answered Oct 20 '22 01:10

Adam Tindale


Pelican looks for templates in whatever directory you've specified as THEME in your pelicanconf.py. If you just want to change what the output looks like, you can modify article.html or page.html in that directory (the default is themes/notmyidea relative to wherever pelican is installed). See how to create themes for Pelican for more.

If you actually want to change the name of the file that Pelican looks for to generate the articles or pages, that's a bit trickier. I don't know of any setting that allows this to be altered, but the relevant bit of the Pelican source appears to be here, so if you really want this you could consider subclassing Content yourself of just changing the relevant lines in your copy of Pelican.

like image 26
James Porter Avatar answered Oct 20 '22 00:10

James Porter