Log in Sign up

Display posts by tags or category

Is it possible to display posts by tags or a single category per post, so that I could have an archive with headings, something like this:


This is a post title, January 1st 2021

An earlier post, December 20th, 2020


My latest post about oranges, June 5th, 2021 …

3 replies Asked Jun 20 '21 at 7:02 · Improve this question

First, you will want to fork an editable version of your template, if you haven't already.

Then add a new view to your template, copying the archives.html view as a starting point.

Into your new view, paste the following template code which will list all of your tags in alphabetical order, and all of the posts associated with each tag!

    <a href="{{{url}}}">{{title}}</a><br>

The template code above should replace the {{#allEntries}} or the {{#archives}} block, depending on which template you copied archives.html from.

Please let me know if you would like me to go into more detail about any of these steps, or if you have any questions!

Answered Jun 22 '21 at 14:23 · Improve this answer

How does one call up the new view? (eg if I have a file named category-archive.html, what would be the hyperlink that will show its contents?)

Answered Jun 22 '21 at 14:43 · Improve this answer

By default, category-archive.html has the URL /category-archive.html.

You can change this in your template's configuration file, which is called package.json. For example, consider the package.json property for archives.html.

Let's say you want category-archive.html to have the URL /categories. You would add the following to the views key in package.json:

    "category-archive.html": {
      "url": "/categories"

Does that make sense? Please let me know if you have any questions about this or anything else

Answered Jun 22 '21 at 15:22 · Improve this answer

Markdown allowed