Basically title. How do I display the first tag in a list of tags (i.e. tags = [“a”, “b”] ) that is declared in the front matter?
Thanks.
Basically title. How do I display the first tag in a list of tags (i.e. tags = [“a”, “b”] ) that is declared in the front matter?
Thanks.
{{ index .Params.tags 0 }}
If thats the case then what am I doing wrong? I am getting a
wrong type for value; expected string; got map[string]interface {}
error here trying to render blog-summary that is in my layouts/default folder with this call:
{{ range first 4 ( after 1 (sort $blogs ".Params.date") ) }}
{ partial "blog-summary" (dict "tags" (index .Params.tags 0) "heading" .Params.subheading "subheading" .Params.length "length" .)}}
{{ end }}
Your partial call is malformed. I’m guessing you want something like this instead:
{{ partial "blog-summary" (dict "tags" (index .Params.tags 0) "heading" .Params.heading "subheading" .Params.subheading "length" .Params.length) . }}
EDIT:
{{ partial "blog-summary" (dict "tags" (index .Params.tags 0) "heading" .Params.heading "subheading" .Params.subheading "length" .Params.length "context" .) }}
I am Using in my site meta but it didn’t work
<meta property="article:tag" content="{{index .Params.tags 1}}">
<meta property="article:section" content="{{index (.Params.categories) 1}}">
Please post a link to the public repository for your site. See:
https://discourse.gohugo.io/t/requesting-help/9132
Include a link to the source code repository of your project, because we really need the context of seeing your templates and partials to be able to help you. It is trivial to do a quick
git clone
on your repo, then runhugo server
in your project, to help you out. On the other hand, recreating your code from screenshots, or sort of guessing at it, is not.
If you can’t share your repository for whatever reason, consider creating a dummy repo that you can share, which reproduces the problem you’re experiencing.