Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to use tags #5

Open
Yura52 opened this issue Apr 8, 2023 · 2 comments · May be fixed by #9
Open

how to use tags #5

Yura52 opened this issue Apr 8, 2023 · 2 comments · May be fixed by #9
Labels
enhancement New feature or request

Comments

@Yura52
Copy link

Yura52 commented Apr 8, 2023

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.

@Yura52 Yura52 changed the title support for tags how to use tags Apr 8, 2023
@InputUsername
Copy link
Owner

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 InputUsername added the enhancement New feature or request label Apr 11, 2023
@kranurag78
Copy link

@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 %}
  • 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.

@kranurag7 kranurag7 linked a pull request Sep 2, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants