I thought I was doing well, then I hit taxonomies. I’m not understanding how to create pages for them or link to them.
The examples in the docs seem a little light and the various themes I’ve looked are are to complex.
In templates, you need categories/list.html, categories/single.html, tags/list.html and tags/single.html. I’m not clear on what to put in those templates, in terms of Tera variables.
Next, if I want to link to those pages, I’m not clear on how this is done. May anyone share a simple example of their work?
Apologies, I think I must be the stupidest person on earth trying to use this tool.
Here you go.
Make sure in config.toml (above the #extras terms) you have:
# Taxonomies
taxonomies = [
{name = "tags", paginate_by = 3, rss = true },
]
Then in list.html (for tags and categories) you have the following code:
{% extends "base.html" %}
{% if page.taxonomies.tags %}
tags:
{% for tag in page.taxonomies.tags %}
<a href='{{ get_taxonomy_url(kind="tags", name=tag) | safe }}'>{{ tag }}</a>
{% endfor %}
{% endif %}
and in single.html:
{% extends "base.html" %}
{% block content %}
{% block title %}
{{ config.title }} · <a href="/tags">Tags</a> · {{ term.name | capitalize }}
{% endblock title %}
<h1>{{ term.name | capitalize }}</h1>
<div class="page-intro">
<p class="larger">View all <a href="/tags">tags</a>.</p>
</div>
<ul class="postlist">
{% for page in term.pages | sort(attribute="date") | reverse %}
<li class="postlist-item">
{% if page.date %}
<div class="date">
<time class="postlist-date">{{ page.date | date(format="%d %B %Y") }}</time>
</div>
{% endif %}
<div class="postlist-head">
<h2><a class="postlist-title" href="{{ page.permalink }}">{{ page.title }}</a></h2>
</div>
<p class="postlist-description">{{ page.description }}</p>
</li>
{% endfor %}
</ul>
{% endblock content %}
Note that this is the basic way I have it set up. You might want a different layout.
1 Like