Use {{url}} in code injection

Hello, I just installed Ghost and am trying to templatize some meta tags for my blog.

I want to use {{url}} in the “Code injection” section for the <head>. But it doesn’t seem to be working.

I’m expecting it to output the current page’s URL but I am not seeing it expanded.

Is this not possible or am I missing something?

This ends up outputting:

<meta property="og:image" content="https://www.mugshotbot.com/m?url={{url absolute='true'}}">

not like what I expected:

<meta property="og:image" content="https://www.mugshotbot.com/m?url=https://joemasilotti.ghost.io/test-post-woo/">

Hi @joemasilotti,
Handlebars syntax wont work in code injection…

Got it, thanks! Is there a security reason for that or is it more of a feature request?

Alternatively, is there a workaround that could get my code snippet working? e.g. the current page URL injected dynamically

Something like this should be done in your theme rather than code injection :)

Think of code injection as a copy->paste into the output HTML; there’s no processing of it at all. All the processing should happen in the handlebars templates

1 Like