Сustom meta for Ghost

I need to make a custom meta, like twitter:image. I inserted it into structured_data.js, but I don’t know how to make my custom meta look like this:

<meta name="relap-image" content = "http: //.jpg">

not like that

<meta property="relap-image" content = "http: //.jpg">

Hi there!

You can add a custom meta tag into your theme if you download it from the Design view in the Ghost admin, and then open the file containing the <head> element. If you’re using Casper it’ll be called “default.hbs” and look like this: Casper/default.hbs at main · TryGhost/Casper · GitHub

You can then add a line of code that looks like this:

{{#post}}
  {{#if feature_image}}
    <meta name="relap-image" content="{{img_url feature_image size="m"}}">
  {{/if}}
{{/post}}

This will add the post feature image into the head whenever there is a feature image. Hope this helps! Let us know how you get on :v:

Thank you David! Your option works, but there is one problem the link to the content is in the format

/content/images/2019/11/pic.png

but we need in the format:

http://kod.ru/content/images/2019/11/pic.png

If you have any ideas or thoughts on how you can change the code to get this kind, let me know. Best regards, Aik.

Ah so you need the absolute URL. You can use the absolute="true" filter to get the full image URL. Like this:

{{#post}}
  {{#if feature_image}}
    <meta name="relap-image" content="{{img_url feature_image size="m" absolute="true"}}">
  {{/if}}
{{/post}}

Thank you David! Your option works!

1 Like