Friday 11 August 2023

Template hook is not being triggered in custom Nikola theme

I am trying to write a custom theme for Nikola, a static site generator. I have been mostly following their tutorial but have run into a problem. I want to show certain HTML specifically on pages (not on posts) in the spot where the page_header template hook appears. So I first ran this command:

nikola theme -c page.tmpl

That copies the base theme's page.tmpl file into my custom theme's directory. That file is actually only 1 line long, simply this:

<%inherit file="story.tmpl"/>

So I added a definition for <%block name="page_header"> ... </%block>. However, the code I defined inside that block does not show up on my pages. Just to make sure I wasn't going crazy, I also defined <%block name="extra_head"> ... </%block> within that same page.tmpl file, and in that case the code contained therein did show up.

Why would the overridden extra_head block work while the overridden page_header block doesn't work within the same template file?



from Template hook is not being triggered in custom Nikola theme

No comments:

Post a Comment