I am getting some global entries from the CMS that I want to use as meta-tags content.

When I load the page I see in the inspection that the meta-tags are moved inside the body. When I remove the dynamic meta-tags and use only the hardcoded, everything is ok.

I have something like that in the head:

{% set metadata = craft.globals.getSetByHandle('metadata') %}

<title>{{ metadata.title }}</title>
<meta name="description" content="{{ metadata.description }}">
<meta name="keywords" content="{{ metadata.keywords}}">

Why the meta-tags are moved? How can I fix that? Is it a Craft issue or a Twig issue or my mistake?

  • OT you can remove that getSetByHandle line completely as global sets get loaded automatically.
    – carlcs
    Sep 29 '16 at 22:02

So the problem was caused by a secret character, the character was not visible in code but it was noticed in the w3c validator for html.

enter image description here

So after removing that character issue solved.

  • 1
    Funny enough the whitespace character was even in your code example in your original question causing Markdown to freak out and not want to treat that line as a code block. Glad you got it sorted!
    – Brad Bell
    Sep 29 '16 at 17:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.