New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

seomatic.meta.setAttributes() does not override rendered tags. #298

HelgeSverre opened this Issue Jan 18, 2019 · 3 comments


None yet
2 participants
Copy link

HelgeSverre commented Jan 18, 2019



I am building a website that uses our plugin Hubspot Connector, to pull in individual blog posts and inserting it into the site (as if it was native content), and wish to inject meta data (title, desc, keywords, featured image) from hubspot into "seomatic"'s tags.

Doing the following does not change the rendered meta tags in any way:

 {% do seomatic.meta.setAttributes({
            seoTitle: post.html_title,
            seoDescription: post.post_summary | default('') | raw,
            seoKeywords: post.keywords,
            seoImage: post.featured_image,
            canonicalUrl: siteUrl,
            twitter: {
                card: "summary_large_image",
                site: siteUrl,
                title: post.html_title,
                description: post.post_summary | default('') | raw,
                image: post.featured_image
            og: {
                type: "article",
                locale: "en_GB",
                url: siteUrl,
                title: post.html_title,
                description: post.post_summary | default('') | raw,
                image: post.featured_image,
        }) %}

The code above is located in the following location templates/blog/_entry.

However as a test, I disabled Automatic rendering in the SEOmatic settings, and tried to place the following snippet BELOW the setAttributes call above:
{{ seomatic.tag.render() }} , The outputted meta tags DO have the correct values, but if i place the same snippet above the previous setAttributes snippet, it does not work.

Which makes me believe that when automatic rendering is enabled, calling seomatic.meta.setAttributes does not do anything.

I was under the impression that you should be able to call that method from anywhere within your teplate (even inside a partial) to override the rendered meta tags, is this a bug, or a misunderstanding of the docs?


seomatic.meta.setAttributes() does not override the attributes if used with automatic rendering enabled, nor if the setAttributes is called after the seomatic.tag.render() method is called.

Which seem to contradict the docs here:

You can set SEOmatic variables anywhere in your templates, even in sub-templates you include from other templates. This works because SEOmatic dynamically injects the meta tags, scripts, links, and JSON-LD into your page after the template is done rendering.


This comment has been minimized.

Copy link

khalwat commented Jan 19, 2019

So I will verify, but seomatic.meta.setAttributes() definitely should work with automatic rendering on; I use just that on several websites.

Can you try clearing the SEOmatic caches? It's possible that the level 2 cache doesn't reflect the changes in your Twig code (yet).

@khalwat khalwat added the need info label Jan 19, 2019


This comment has been minimized.

Copy link

HelgeSverre commented Jan 19, 2019

@khalwat That seem to have worked, it is now working as expected


This comment has been minimized.

Copy link

khalwat commented Jan 19, 2019

If you work in local dev with devMode on, the cache duration is set very short, so you should see those changes rapidly there, without having to clear your caches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment