Tags in default.hbs#head not working (SEO / meta robots)

I have this snippet in the head section of default.hbs:

  {{! Page Meta }}
  <title>{{meta_title}}{{#is "post, page"}} — {{@site.title}}{{/is}}</title>
  {{#has tag="hash-seo-disallowed"}}
      <meta name="robots" content="noindex, nofollow">
  {{/has}}

  <meta name="tags" content="{{tags autolink='false' visibility='all' separator=', '}}" />

However it does not display any tags at all. I know the posts and pages have tags on them, what am I missing? - It cannot be outside the scope(?), since {{meta_title}} works just fine…

Ghost-CLI version: 1.15.3
Ghost version: 3.39.3

Thanks,
Flemming

Try

<meta name="tags" content="{{#get 'tags' limit='all'}}{{#foreach tags}} {{ name }} {{/foreach}}{{/get}}" />/>

and to add a ,

<meta name="tags" content="{{#get 'tags' limit='all'}}{{#foreach tags}}{{#unless @first}},{{/unless}}{{ name }}{{/foreach}}{{/get}}" />

REF:

@ahmadajmi, thanks for the reply, it got me thinking.

I meant tags for a specific page or post, so it’ll be something like this:

  {{! Page Meta }}
  <title>{{meta_title}}{{#is "post, page"}} — {{@site.title}}{{/is}}</title>
  {{#is "post, page"}}
    {{#post}}
      {{#has tag="#seo-disallowed,#hero-card"}}
        <meta name="robots" content="noindex, nofollow">
      {{/has}}
      <meta name="tags" content="{{tags autolink='false' visibility='all' separator=', '}}" />
    {{/post}}
  {{/is}}

It’s bit quirky, but I use pages for hero-cards, and just figured out that Google crawls them and puts them on prominent display in the search results.

This works technically within the templates, but it remains to be seen how Googlebot handles it.

1 Like