Specific title for taxonomies pages

Hi,

I’m using the two default taxonomies : tag & category

I want specific titles for pages from \layouts\taxonomy\tag.html & \layouts\taxonomy\category.html
For tags, I want : “Tag [tag]” and for categories, I want : “Category [category]”

For now I’m using this in my header.html :

{{ if eq .Kind "taxonomy" }}
<title>Taxonomy {{ .Title }}</title>
{{ else }}
<title>{{ .Title }}</title>
{{ end }}

So actually titles for tags are “Taxonomy [tag]” and titles for categories are “Taxonomy [category]”.
But I want “Tag [tag]” & “Category [category]”.

Regards.

I don’t think there is a variable for taxonomy name. You will need to add more conditional logic, or create your own array and pull from that.

You can probably keep it simple using with instead of if.

Try content/taxonomy/_index.md and put front matter title in. Have the same and it works.

I don’t think that is what the OP is asking for. I know they use confusing examples, but I think they are trying to get the “Taxonomy” in their code snippet to say either Tag or Category, depending on the name of the taxonomy, not the term title.

So when they say:

So actually titles for tags are “Taxonomy [tag]” and titles for categories are “Taxonomy [category]”.
But I want “Tag [tag]” & “Category [category]”.

I believe they mean:

So actually titles for tags are “Taxonomy [Earth]” and titles for categories are “Taxonomy [Planet]”.
But I want “Tag [Earth]” & “Category [Planet]”.

Or I misunderstanding. :slight_smile:

@Geonov Since you’re on a taxonomy template, you can use {{ .Data.Singular | title }}.

To generate the full title string you could do {{ print (.Data.Singular | title) " " .Title }}

Thanks guys. Maiki is right.

{{ if eq .Kind "taxonomy" }}
<title>{{ .Data.Singular }} {{ .Title }}</title>
{{ else }}
<title>{{ .Title }}</title>
{{ end }}

did the trick.

Thanks guayom.