how to use tags
Closed this issue · 2 comments
Thanks!
I currently have no use for a tags system on my own website, but it shouldn't be too hard to implement on top of the theme. Basically it would involve overriding the page template (page.html) to add a list of tags to posts, creating "tag list" and "tag page" templates, and adding those pages (as markdown).
I'd also be happy to help out if you wanna make a PR for the theme itself.
(Too busy to implement this myself at the moment, sorry!)
@InputUsername After looking at some other themes I tried the following. I created two files under templates directory taxonomy_list.html
and taxonomy_single.html
Following is the content of taxonomy_list.html
{% extends "page.html" %}
{% block main %}
<main>
<small>
<div>
<h1> tags </h1>
{% set tags = get_taxonomy(kind="tags") %}
{% for post in tags.items %}
<a href="{{ post.permalink }}">#{{ post.name }}</a>
{% endfor %}
</div>
</small>
</main>
{% endblock %}
config.toml
and tags in markdown document looks following.
taxonomies = [
{ name = "tags" }
]
title = "rust-blog"
[taxonomies]
tags = ["rust", "ssg", "other"]
When invoking zola serve
I'm getting the following errors.
zola serve
Building site...
Checking all internal links with anchors.
> Successfully checked 0 internal link(s) with anchors.
-> Creating 7 pages (0 orphan) and 2 sections
Error: Failed to serve the site
Error: Failed to render a list of tags page.
Error: Reason: Failed to render 'taxonomy_list.html' (error happened in a parent template)
Error: Reason: Variable `page.title` not found in context while rendering 'taxonomy_list.html'
Can you help me with this? I'm happy to create a PR if this is fixed and add tags support to the theme.