Allow taxonomy with limitations

#1

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?

#2

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.

#3

See the disableKinds option.

2 Likes
#4

Forgot about that one.

#5

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].

#6

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.

#7

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…

#8

disabledKinds = [“taxonomyTerm”]

2 Likes
#9

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

1 Like
#10

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>
Section included in sitemap, even if it is not rendered?
Custom Robots.txt and sitemap.xml Templates