Make category/categories of page show at the bottom of the article

Hi,

I want to show the category/categories of an article at the bottom of the article.

I want to link to the category/categories of an article at the bottom of the article.

How can I do this?

Add something like this to relevant place in your layout

{{ with .GetTerms "categories" }}
    <div class="article-category">
        {{ range . }}
        <a class="category-link" href="{{ .Permalink }}">{{ .LinkTitle }}</a>
        {{ end }}
    </div>
{{ end }}
1 Like

Thank you.

It works.

What if I want to display two categories like this?

Read more articles about: Category1, Category2

With a comma (,) in between if there are two categories or tags.

But no comma if there’s only one category.

It will be something like that

{{ with .GetTerms "categories" }}
      <div class="article-category">
          {{ range $i, $_ := . }}{{ if $i }}, {{ end }}<a class="category-link" href="{{ .Permalink }}">{{ .LinkTitle }}</a>{{ end }}
      </div>
{{ end }}
1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.