getnikola / nikola-themes

Themes for Nikola
https://themes.getnikola.com/
70 stars 51 forks source link

[material-theme] how to display category of a blogpost inside the blogposting #199

Closed horstjens closed 3 years ago

horstjens commented 3 years ago

Using the material theme with nikola, i struggle to understand how to display the category of a blogpost automatically (next to the automatic-generated list of tags) in a blogpost.

I understand that i can link from the navbar to the category overview page to display all tags and all categories, but i want that

Kwpolska commented 3 years ago

That’s not a conf.py setting, but you can easily implement this on your own by changing the post.tmpl template (look at the html_tags macro for an example on how to format it, the category name should be available in post.meta["category"]).

horstjens commented 3 years ago

Thank You @Kwpolska ! I was able to code the desired effect for my blog's default language, but now i struggle to make the link aware of a translated language.

I did this (main language is "de") inside the file post.tmpl: `

Kwpolska commented 3 years ago

You can use the _link function. This should work (untested):


<a href="{{ _link('category', post.meta('category'), lang) }}">{{ post.meta('category') }}</a>
horstjens commented 3 years ago

Thank you @Kwpolska, it worked !