Modify a display according to the context

Hello,

I currently need help to modify a display according to the context.
I am using Hugo (v. 0.84.3 extended), and I am using the GeekDoc theme. This one doesn’t support tags, so I’m implementing them to contribute.
Currently, whether I display the list of tags or the list of articles corresponding to the selected tags
the CSS remains the same :slight_smile:


I’ve read the documentation, but I don’t know how to do it.
I would like to be able to differentiate the CSS according to what my page displays :

{{ define "main" }}
  {{ partial "page-header" . }}

  {{ range (.Paginator 100).Pages.ByTitle }}

  <div class="tags gdoc-markdown__align--{{ default "left" (.Page.Params.GeekdocAlign | lower) }}">
    <a class="tag-link" href="{{ .RelPermalink }}">{{ partial "title.html" . }}</a>
  </div>

  {{ end }}
{{ end }}

Thank you for your time and your help.

There are at least a couple of ways to approach this:

  1. Create a unique template using the rules described here:
    https://gohugo.io/templates/lookup-order

  2. Use conditional logic within the template based on the page’s kind. For example:

    {{ if eq .Kind "term" }}
      ...
    {{ else }}
      ...
    {{ end }}
    
1 Like

Hello,
Thanks for your help !

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