Categories tags in post?

Is there a way to have your categories show as tags and the end of your post? I know some Themes have the ability to show tags. I am currently using Kiko (I know no matter how many others I try I come back to the same, for now). Is there a way to make this happen in Kiko?

Wherever you want the categories to show up, put this in your template:

{{ range .Params.categories }}{{ . }}{{ end }}
would it be somewhere like `layouts/_default/list.html`

Actually I think it would be more in

layouts/post/single.html

That worked, is there a way to make them clickable at all?

probably something like:

{{ range .Params.categories }}
<a href="{{ .Site.BaseURL }}/categories/{{ . | urlize }} >}}"> {{ . }} </a>
{{ end }}

I will try this,

Thank you so much for your help

I am presuming I did something wrong :sweat_smile:

My fault-- I forgot to remove a >}}.

{{ range .Params.categories }}
<a href="{{ .Site.BaseURL }}/categories/{{ . | urlize }}"> {{ . }} </a>
{{ end }}

Since you’re going to have more than one, you may want to do something like this:

<span class = "categories">
{{ range .Params.categories }}
<a href="{{ .Site.BaseURL }}/categories/{{ . | urlize }}"> {{ . }} </a>
{{ end }}
</span>

and add this to your CSS:

categories {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

Will try this

okay I get this

This is what i have in the template:

{{ define "main" }}
<header class="masthead">
  <h1 class="masthead-title--small">
    <a href="/">{{ .Site.Title }}</a>
  </h1>
</header>
<div class="content post h-entry">
	{{ if .Title }}
		<h1 class="page-title">{{ .Title }}</h1>
	{{ end }}
  <div class="post-date">
    <time class="dt-published" datetime="{{ .Date.Format "2006-01-02 15:04:05 -0700" }}">{{ .Date.Format "Jan 2, 2006" }}</time>
  </div>
  <div class="e-content">
  {{ .Content }}
{{ partial "reply-by-email.html" . }}
{{ range .Params.categories }}
<a href="{{ .Site.BaseURL }}/categories/{{ . | urlize }} >}}"> {{ . }} </a>
{{ end }}
</span>
  </div>
</div>

{{ if .Site.Params.include_conversation }}
<script type="text/javascript" src="https://micro.blog/conversation.js?url={{ .Permalink }}"></script>
{{ end }}

{{ end }}

You didn’t correct the code to match the post where I said “my fault”.

The problem is the extra >}} that I forgot to delete at the end of the opening <a> tag.

Ah! I see it, my bad, so far no errors! :grinning:

deleted the > {{

Now I get something different

Theme error: Error building site: failed to render pages: render of “page” failed: execute of template failed: html/template:post/single.html: “<” in attribute name: “\n”

Oh I removed the wrong thing , I think

Just to say this is working for me on Tufte template. Thankyou

1 Like

@Gaby - @amit had this working on his Musings theme. He sent me the link and I was able to get it working on my customized Marfa theme.

You just have to add the script to single.html.

Thanks again, Amit!

1 Like