Hi everyone,
I have a hugo site where the content files are generated in the content folder based on a script.
The content file structure is like this:
content
└─graphs
└──departments
└───service-groups
└────│ service1.md
└────│ service2.md
Inside every service md file it is used a shortcode:
{{< service-shortcode >}}
There is the graphs/list.html layout where a partial is used to render the content of the pages:
{{ range $pages }}
{{ partial "li-graphs.html" . }}
{{ end }}
The li-graphs.html file renders the content:
<div> {{ .Content }} </div>
<div>
<a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
</div>
The result is a page where every service (md file) is rendered in a list template and when you click on the service title (a href) it will navigate to a default single template displaying the content of the service.
I want to add an additional html element in the shortcode if the shortcode is displayed in a single template.
How can I identify in the shortcode if it’s rendered in the list template or in the single template?
Smth like:
{{ if isSingleTemplate }}
<h1> Single template </h1>
{{ end }}
<div> Shortcode content</div>
I tried using the page variables: .isPage, .isNode, .isSection, etc and it doesn’t work.
And I also tried with .Page.Permalink but it gives the same url on the list and single templates.
Is there another way of doing this using hugo’s features?