Check if the current path in gohugo matches a pattern with regex

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:

There’s also an undocumented function strings.Contains

{{ $haystack := "The big brown dog" }}
{{ $needle := "brown" }}
{{ strings.Contains $haystack $needle }} --> true