# \[Hugo\] Add prefix "Posts by tag" line whenever creating new tag

**URL:** https://discourse.gohugo.io/t/hugo-add-prefix-posts-by-tag-line-whenever-creating-new-tag/37349
**Category:** support
**Tags:** taxonomy
**Created:** [February 24, 2022, 1:55am UTC](https://discourse.gohugo.io/t/hugo-add-prefix-posts-by-tag-line-whenever-creating-new-tag/37349 "2022-02-24T01:55:25Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![buinguyenhoangtho](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/buinguyenhoangtho/32/13238_2.png) [@buinguyenhoangtho](https://discourse.gohugo.io/u/buinguyenhoangtho)
#### Post date: [February 24, 2022, 1:55am UTC](https://discourse.gohugo.io/t/hugo-add-prefix-posts-by-tag-line-whenever-creating-new-tag/37349/1 "2022-02-24T01:55:25Z")

</div>

Hi guys, sorry the question kinda confused. But is possible that make Hugo add prefix “Post by [tag]” in title everytime i create new tag by adding to the post?

Example below is the post that i created. I have an tag(the) params call **Example**. So i published the post and the **markdown** tag is created. But when i click on the tag, in web browser the title is only show **markdown**. The complete title i want is “Posts by tag **markdown** ”  
I want to make an “prefix” like "Posts by + **[tag that i created in frontmatter]**" Is possible to do it on Hugo?  
Thanks

```auto
---
title: "Rich Content"
date: "2019-03-10"
summary: "A brief summary of Hugo Shortcodes"
danhmuc:
  - talkshow
tag: 
    - markdown
---

```

My head.html now:

```auto
{{ $title := print .Site.Title " | " .Title }}
    {{ if .IsHome }}{{ $title = .Site.Title }}{{ end }}
    <title>{{ $title }}</title>

```

---

<div class="post-metadata">

### Author: ![pamubay](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pamubay/32/17838_2.png) [@pamubay](https://discourse.gohugo.io/u/pamubay)
#### Post date: [February 24, 2022, 3:16am UTC](https://discourse.gohugo.io/t/hugo-add-prefix-posts-by-tag-line-whenever-creating-new-tag/37349/2 "2022-02-24T03:16:26Z")

</div>

```auto
{{ $title := print .Site.Title " | " .Title }}
{{ if .IsHome }}{{ $title = .Site.Title }}{{ end }}

{{ if eq .Kind "term" }} 
  {{ $title = printf "Posts by tag %s" .Title }}
{{ end }}
<title>{{ $title }}</title>

```

About Page Kind:

> **[Section Page Templates](https://gohugo.io/templates/section-templates/#page-kinds)**
>
> Templates used for section pages are \*\*lists\*\* and therefore have all the variables and methods available to list pages.

---

<div class="post-metadata">

### Author: ![buinguyenhoangtho](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/buinguyenhoangtho/32/13238_2.png) [@buinguyenhoangtho](https://discourse.gohugo.io/u/buinguyenhoangtho)
#### Post date: [February 24, 2022, 9:57am UTC](https://discourse.gohugo.io/t/hugo-add-prefix-posts-by-tag-line-whenever-creating-new-tag/37349/3 "2022-02-24T09:57:00Z")

</div>

> [@pamubay](#):
>
> ```auto
> {{ $title := print .Site.Title " | " .Title }}
> {{ if .IsHome }}{{ $title = .Site.Title }}{{ end }}
> 
> {{ if eq .Kind "term" }} 
> {{ $title = printf "Posts by tag %s" .Title }}
> {{ end }}
> <title>{{ $title }}</title>
> 
> ```

Thanks you so much. One last thing, I forgot to ask, i have 2 taxonomy, **tag** and **category**.  
It work with **tag** , but can above method also working with **category** too? I’m using both for my blog

---

<div class="post-metadata">

### Author: ![pamubay](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pamubay/32/17838_2.png) [@pamubay](https://discourse.gohugo.io/u/pamubay)
#### Post date: [February 24, 2022, 10:36am UTC](https://discourse.gohugo.io/t/hugo-add-prefix-posts-by-tag-line-whenever-creating-new-tag/37349/4 "2022-02-24T10:36:58Z")

</div>

You can combine it with `.Data.Singular` to get the taxonomy name i.e. `tags`/`categories`

```auto
{{ $title := print .Site.Title " | " .Title }}
{{ if .IsHome }}{{ $title = .Site.Title }}{{ end }}

{{ if eq .Kind "term" }} 
  {{ $title = printf "Posts by %s %s" .Data.Singular .Title }}
{{ end }}
<title>{{ $title }}</title>

```

More about Taxonomy Term Page Variables:

> **[Taxonomy Variables](https://gohugo.io/variables/taxonomy/#taxonomy-terms-page-variables)**
>
> Taxonomy pages are of type \`Page\` and have all page-, site-, and list-level variables available to them. However, taxonomy terms templates have additional variables available to their templates.

---

<div class="post-metadata">

### Author: ![buinguyenhoangtho](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/buinguyenhoangtho/32/13238_2.png) [@buinguyenhoangtho](https://discourse.gohugo.io/u/buinguyenhoangtho)
#### Post date: [February 24, 2022, 10:58am UTC](https://discourse.gohugo.io/t/hugo-add-prefix-posts-by-tag-line-whenever-creating-new-tag/37349/5 "2022-02-24T10:58:37Z")

</div>

> [@pamubay](#):
>
> ```auto
> {{ $title := print .Site.Title " | " .Title }}
> {{ if .IsHome }}{{ $title = .Site.Title }}{{ end }}
> 
> {{ if eq .Kind "term" }} 
> {{ $title = printf "Posts by %s %s" .Data.Singular .Title }}
> {{ end }}
> <title>{{ $title }}</title>
> 
> ```

Thanks once again.! \<3. How can i close the thread with your solution btw?

---

<div class="post-metadata">

### Author: ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)
#### Post date: [February 26, 2022, 10:59am UTC](https://discourse.gohugo.io/t/hugo-add-prefix-posts-by-tag-line-whenever-creating-new-tag/37349/6 "2022-02-26T10:59:39Z")

</div>

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