Allow taxonomy with limitations

I would like to continue using taxonomies such as categories and tags, but want to eliminate (or present a 404 to) the /categories/ and /tags/ URIs, while still allowing /categories/x-category and /tags/x-tag. Is that possible?

In config.toml include the following

[taxonomies]
tags = ""
categories = ""

This will throw warnings in the console but it is currently the only way to use taxonomies for internal purposes without rendering their URIs.

See the disableKinds option.

2 Likes

Forgot about that one.

Setting disabledKinds = "taxonomy" will disable everything. I still want to use categories, and tags, I just don’t care about listing of them in one page, winch happens if I go to /categories/, or /tags/.

Same happens with the "" under [taxonomies].

Ah. I just read the above part in your original post. No what you want to do is not possible.

You cannot turn off taxonomy pages and only render the taxonomy terms list pages.

Any known hack, or workaround to accomplish what I am after? Anything you could think of? I tried doing it on the server side, but issuing a 404 for /categories/ and /tags/ will also render 404 for any directories underneath, which isn’t what I want…

disabledKinds = [“taxonomyTerm”]

2 Likes

Excellent, this does what I want! Thank you very much.

1 Like

No. But you can hide these pages so that search engines cannot index them.

Replicate your taxonomies as a folder structure under /content/ and then in the _index.md add the following parameter:

+++
hidden      = "true"
+++

And then in the head partial of your site you could include

{{ with .Params.hidden }}<meta name="robots" content="noindex">{{ end }}

Also change your sitemap.xml template under /layouts/ to:

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  {{ range .Data.Pages }}{{ if not .Params.hidden }}
  <url>
    <loc>{{ .Permalink }}</loc>
    {{ with .Sitemap.ChangeFreq }}
    <changefreq>{{ . }}</changefreq>{{ end }}{{ if ge .Sitemap.Priority 0.0 }}
    <priority>{{ .Sitemap.Priority }}</priority>{{ end }}
  </url>
  {{ end }}{{ end }}
</urlset>
1 Like