nystudio107 / craft-seomatic

SEOmatic facilitates modern SEO best practices & implementation for Craft CMS 3. It is a turnkey SEO system that is comprehensive, powerful, and flexible.
https://nystudio107.com/plugins/seomatic
Other
166 stars 71 forks source link

Using override in template not working #169

Closed alanski66 closed 6 years ago

alanski66 commented 6 years ago

So using a switch for entry.type {% switch entry.type %} {% case 'oldnews' %} {% set asset = entry.oldNewsImage.one() %} {% do seomatic.meta.ogDescription("{entry.body}") %} {% do seomatic.meta.ogImage("{asset.url}") %}

{% case 'news' %} {% set asset = entry.image.one() %} {% do seomatic.meta.ogDescription("{entry.newsIntro}") %} {% endswitch %}

Then using below to render different meta ogImage based on switch {% do seomatic.meta.ogImage("{asset.url}") %}

No og:image is output asset.url definitely has a value

Am I using this correctly?

khalwat commented 6 years ago

Looks fine to me; are you sure the code actually runs?

Try putting just this with no conditionals:

{% do seomatic.meta.description("Some Description") %}

... and then clear the SEOmatic caches, and view the source. lmk

alanski66 commented 6 years ago

Thanks. Just to check my understanding - custom 'do' calls to seomatic that are present in the template should override everything right?

On this basis that code doesn't look like it runs for facebook or standard meta

{% do seomatic.meta.ogDescription("moo cow") %} {% do seomatic.meta.description("Some Description") %}

None of the above outputs anything in meta data after cache cleared. Have tried this in multiple places in template but never see the override output. Updated to 14/7 release too. Am I misunderstanding how this is meant to work?

alanski66 commented 6 years ago

OK solved now. Total misfire on my end after small change to development environment and looking at the wrong templates. Thanks Andrew for patience and great tool

khalwat commented 6 years ago

Great. glad you got it sorted!