Custom Taxonomies not filtering properly

Hello Hugo,

I’ve got a simple question I believe. I am trying to create multiple blogs on one site. Each blog type will have its own custom tag. Here is what I have defined in my config.toml

[taxonomies]
  tag = 'tags'
  unraidTag = 'unraidTags'
  gameTrackingTag = 'gameTrackingTags'

[permalinks]
  blog = "/:slug/"
  tags = "/blog/:slug"
  unraid-details = "/:slug"
  unraidTags = "/unraid-details/:slug"
  game-tracking-details = "/:slug"
  gameTrackingTags = "/game-tracking-details/:slug/"

The custom tags are working properly for displaying on the respective page types, but once I start filtering on the tags the filter no longer applies. (It worked when I only had the one blog and tag type)

Here is what the filter system looks like.

{{ if .Data.Singular }}
  <h3 style="margin-bottom:0">Filtering for "{{ .Title }}"</h3>
  <small>
    {{ if eq .Type "tags" }}
      <a href="{{ "blog" | relURL }}">Remove filter</a>
    {{ else if eq .Type "gameTrackingTags" }}
      <a href="{{ "game-tracking-details" | relURL }}">Remove filter</a>
    {{ else if eq .Type "unraidTags" }}
      <a href="{{ "unraid-details" | relURL }}">Remove filter</a>
    {{ end }}
  </small>
  {{ end }}

I noticed that when I click on one of the custom tags, the URI becomes /gametrackingtags/bungie/ instead of the expected /game-tracking-details/bungie/, but the blogs tag works properly, displaying as /blog/games/.

What am I missing here?

I solved this just now. Turns out I didn’t even post the part that was filtering lol. This was the fix. Would love a code review to help refactor to something better.

<ul class="blog-posts">
    {{ if eq .Type "blog" }}
      {{ range .Pages }}
      <li>
        <span>
          <i>
            <time datetime='{{ .Date.Format "2006-01-02" }}' pubdate>
              {{ .Date.Format (default "02 Jan, 2006" .Site.Params.dateFormat) }}
            </time>
          </i>
        </span>
        <a href="{{ .Permalink }}">{{ .Title }}</a>
      </li>
      {{ else }}
      <li>
        No posts yet
      </li>
      {{ end }}
    {{ else if eq .Type "game-tracking-details"}}
      {{ range .Data.Pages.ByDate }}
      <li>
        <span>
          <i>
            <time datetime='{{ .Date.Format "2006-01-02" }}' pubdate>
              {{ .Date.Format (default "02 Jan, 2006" .Site.Params.dateFormat) }}
            </time>
          </i>
        </span>
        <a href="{{ .Permalink }}">{{ .Title }}</a>
      </li>
      {{ else }}
      <li>
        No posts yet
      </li>
      {{ end }}
    {{ else if eq .Type "unraid-details"}}
      {{ range .Data.Pages.ByTitle }}
      <li>
        <a href="{{ .Permalink }}">{{ .Title }}</a>
      </li>
      {{ else }}
      <li>
        No posts yet
      </li>
      {{ end }}
    {{ end }}
    {{ if eq .Type "tags" }}
      {{ range .Pages }}
      <li>
        <span>
          <i>
            <time datetime='{{ .Date.Format "2006-01-02" }}' pubdate>
              {{ .Date.Format (default "02 Jan, 2006" .Site.Params.dateFormat) }}
            </time>
          </i>
        </span>
        <a href="{{ .Permalink }}">{{ .Title }}</a>
      </li>
      {{ else }}
      <li>
        No posts yet
      </li>
      {{ end }}
    {{ else if eq .Type "gameTrackingTags"}}
      {{ range .Data.Pages.ByDate }}
      <li>
        <span>
          <i>
            <time datetime='{{ .Date.Format "2006-01-02" }}' pubdate>
              {{ .Date.Format (default "02 Jan, 2006" .Site.Params.dateFormat) }}
            </time>
          </i>
        </span>
        <a href="{{ .Permalink }}">{{ .Title }}</a>
      </li>
      {{ else }}
      <li>
        No posts yet
      </li>
      {{ end }}
    {{ else if eq .Type "unraidTags"}}
      {{ range .Data.Pages.ByTitle }}
      <li>
        <a href="{{ .Permalink }}">{{ .Title }}</a>
      </li>
      {{ else }}
      <li>
        No posts yet
      </li>
      {{ end }}
    {{ end }}
  </ul>

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