Common taxonomies templates


#1

It seems I do something wrong. I have next taxonomies:

  • Articles
  • Labels

And there are relevant templates:

  • article.html
  • article.terms.html
  • label.html
  • label.terms.html

My problem is that the templates are identical.

article.html

{{ partial "prefix.html" . }}
{{ partial "header.html" . }}
<main>
  <div class="container">
    <div class="row">
      <h1>Article {{ .Title }}</h1>
      {{ range .Data.Pages }}
      <div class="col s12 m3 l4">
        <div class="label-box">
          <a href="">{{ .Title }}</a>
        </div>
      </div>
      {{ end }}
    </div>
  </div>
</main>
{{ partial "footer.html" . }}
{{ partial "suffix.html" . }}

same as lable.html

{{ partial "prefix.html" . }}
{{ partial "header.html" . }}
<main>
  <div class="container">
    <div class="row">
      <h1>Label {{ .Title }}</h1>
      {{ range .Data.Pages }}
      <div class="col s12 m3 l4">
        <div class="label-box">
          <a href="">{{ .Title }}</a>
        </div>
      </div>
      {{ end }}
    </div>
  </div>
</main>
{{ partial "footer.html" . }}
{{ partial "suffix.html" . }}

Can I somehow group them together?


#2

Every page generated by Hugo follows a template lookup order. The templates you are talking about follow the lookup order for taxonomy list templates. So you can probably put that template at /layouts/_default/taxonomy.html.


#3

Thanks! You’re right.