How to Do SEO for Taxonomies?


I want to do SEO of my categories and tags where I can add SEO Specific Title, Description and Open Graph Image.

I am currently hosting posts and pages in the content folder

 - knowledge-base
 - posts
 - pages

while the taxonomies are hosted in data folder

 - categories
   - cat-1.toml
   - cat-2.toml
 - tags
   - tag-1.toml
   - tag-1.toml

How can I show data from categories to meta data?

or is there any other way?

you can access the data files with:

{{ }}

if your cat-1.toml looks like this:

parametername = "blafasel"

If you have the taxonomy you can use a construct like this:

{{ (index site.Data.categories $category).parametername }}

Where $category is set somewhere as existing filename/category.

I am doing something like this

    {{ $category := .Data.Term }}
    <title>{{ (index site.Data.categories $category).seo_title }}</title>

and my category file looks like

name = "Guides"
seo_title = "Guides & How-To | Get a Solution to Each Problem"

But that returns a problem!

<index site.Data.categories $category>: error calling index: value is nil; should be of type string

Without a sample repo we can’t know. It could be, that one of the categories is missing, it could be, that .Data.Term is not set.

you can create files in content/categories ands content/tags.
set the SEO text in frontmatter and and use it in the section list template