InputUsername / zola-hook

A clean and simple personal site/blog theme for the Zola static site generator
https://inputusername.github.io/zola-hook/
35 stars 18 forks source link

how to use tags #5

Closed Yura52 closed 2 weeks ago

Yura52 commented 1 year ago

Hi! Thank you for the great theme! It is very nice to see a minimal theme with a dark mode support. I wonder if it is possible to add tags to posts and list them in a dedicated page? E.g. see how it is done in the "anpu" theme: github, demo.

InputUsername commented 1 year ago

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!)

kranurag78 commented 1 year ago

@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>&nbsp;
        {% endfor %}
      </div>
    </small>
  </main>
{% endblock %}