1

I've got a few pages on my site that are not content managed.

I don't want to create entries for these pages, but I do want the SEO for these pages content managed.

My solution here has been to set up a global matrix block, with each block having a handle and seomatic field.

This way the SEO for these non-entries is content managed, but the pages themselves aren't.

Is there a way for me to tell SEOMatic to render a custom SEOMatic field? I tried {% do seomatic.meta.setAttributes(myCustomSeoMetaField) %} but had no luck, and can't see anything in the docs.

PS the reason I want to do it this way is partly because the Global/default SEOMatic settings didn't seem to be coming through on a non-entry, so I was hoping using some sort of default hook will take care of this also.

1 Answer 1

2

So the default global settings for SEOmatic should definitely be applied to pages that don't have corresponding entries in the CMS. That's what the global defaults do.

By far the easiest way to do what you want is just to create a Single that corresponds to these otherwise non-managed pages, and then you can set up whatever you like in the corresponding Content SEO settings.

If you don't want to do that, you can set everything yourself via the Twig API:

https://nystudio107.com/docs/seomatic/Using.html#seomatic-variables

You could try doing something like:

{% do seomatic.meta.setAttributes(myCustomSeoMetaField.metaGlobalVars)
%}

As per: https://nystudio107.com/docs/seomatic/Fields.html#template-access

But in general, I think this is a rougher work-around than just creating a Single for the previously non-content managed pages.

To be clear:

PS the reason I want to do it this way is partly because the Global/default SEOMatic settings didn't seem to be coming through on a non-entry, so I was hoping using some sort of default hook will take care of this also.

This should not happen. You absolutely should get the default SEO settings on every page, so if this isn't happening for you, something deeper is wrong.

1
  • Thanks! You answered my actual question, and also made me dig deeper on the root issue, which was that I've got a multisite setup and hadn't configured SEOMatic for both sites, hence nothing being pulled through.
    – mijewe
    Commented Jun 18, 2020 at 9:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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