There’s an easier way to do this.
When you’re visiting http://localhost:1313/tags/
or http://localhost:1313/tags/foo/
Code | Value |
---|---|
{{ .Data.Singular }} |
tag |
{{ .Data.Plural }} |
tags |
When you’re visiting http://localhost:1313/categories/
or http://localhost:1313/categories/bar/
Code | Value |
---|---|
{{ .Data.Singular }} |
category |
{{ .Data.Plural }} |
categories |
If you really need to compare strings, see:
- https://gohugo.io/functions/urls.parse/
- https://gohugo.io/functions/in/
- https://gohugo.io/functions/findre/
There’s also an undocumented function strings.Contains
…
{{ $haystack := "The big brown dog" }}
{{ $needle := "brown" }}
{{ strings.Contains $haystack $needle }} --> true