How to set `pagekind`?

43 views
Skip to first unread message

Michael Forbes

unread,
Mar 26, 2018, 12:05:14 AM3/26/18
to nikola-discuss
I noticed in the documentation that one can check `pagekind` in themes.  How does one set this for a particular page (in particular, I am trying to set `front_page` for my main index page.)  I am using RST pages, and tried things like adding `.. pagekind: front_page` as part of the header but none of this seems to work.  If I should be doing something else instead, please let me know.

Aside: I am trying to modify some existing HTML templates to make a new theme and need to figure out how to specify that certain pages should have certain properties in the new theme.  I know I could write a plugin and make custom directives etc. but that seems overkill.  Any suggestions as to the best way to tag that a page should have certain properties in the theme would be welcome.

Thanks,
Michael.

Roberto Alsina

unread,
Mar 26, 2018, 11:06:54 AM3/26/18
to nikola-...@googlegroups.com
If you want your templates to make decisions based on post/page metadata, just use whatever metadata you want, and ask the users to provide it :-)

--
You received this message because you are subscribed to the Google Groups "nikola-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nikola-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Message has been deleted
Message has been deleted

Roberto Alsina

unread,
Mar 27, 2018, 7:17:43 AM3/27/18
to nikola-...@googlegroups.com
To add arbitrary metadata to a post just do it.

For example, if you are using nikola style metadata that looks like

.. title: foo

You can add your own called frobnozz by adding a line such as

.. frobnozz: whatever

As for how to use it in the template: in all places where it makes sense you will have a post object. Use it as the other metadata is used (something like post.meta('frobnozz') ) but really look for an example because I am on a train and can't reach the docs right now and don't remember :)

El mar., 27 de mar. de 2018 8:14 AM, Michael Forbes <michael...@gmail.com> escribió:
I see how I can use tags or something similar to set metadata, but do not see how I can set arbitrary or custom pieces of metadata without creating plugin.  Also, the `pagekind` variable seems like exactly what I need, but I could not find a way of setting it.  In the meantime I found that I could use a test like {% if permalink == "/" %} but I don't know how robust that is.

Michael Forbes

unread,
Apr 3, 2018, 11:22:49 PM4/3/18
to nikola-discuss
Thanks Roberto, somehow I did not clue in that I could add arbitrary metadata!  Thanks for the example.  That works well.
Reply all
Reply to author
Forward
0 new messages