ethercreative / seo

SEO utilities including a unique field type, sitemap & redirect manager
MIT License
269 stars 96 forks source link

Overriding seo isn't working. #392

Open anchovy opened 2 years ago

anchovy commented 2 years ago

Description

I'm using the simular syntax as per #66 but it's not overriding the existing seo settings output.

I'm out case - we've got loads of commerce products, and unless an admin has specifically set a social image we want to use our mobile image - so our code is

{% set seo = product.seo %}
{%- if seo.social.facebook.imageId == '' -%}

    {% set seo = product.seo %}
    {% set seo = craft.seo.custom(
        seo.title, 
        seo.description, 
        false,
        {
            twitter: { image: productData.bannerImageMobile.one },
            facebook: { image: productData.bannerImageMobile.one },
        }
    ) %}

{%- endif -%}

The logic abive is if the facebook image isn't specifically set, then the twitter image won't be either.

If I {{dump(seo)}} this data out in the template afterwards the imageId has been updated to the custom imageId as specified above, but in the html generated by the {% hook seo %} it's still either showing the default social image?

Steps to reproduce

1. 2.

Additional info