vaersaagod / seomate

SEO, mate! It's important. That's why SEOMate provides the tools you need to craft all the meta tags, sitemaps and JSON-LD microdata you need - in one highly configurable, open and friendly package - with a super-light footprint.
MIT License
36 stars 8 forks source link

Replace empty meta values with null #11

Closed michaelhue closed 5 years ago

michaelhue commented 5 years ago

Unfortunately Craft saves many empty fieldtypes as empty string (e.g. the Color field). As a result many meta tags contain empty values.

I recommend replacing empty string values with null.

aelvan commented 5 years ago

Hi,

Not sure I follow. Is it the fact that a meta tag is output even though the resulting value is an empty string, you mean? Could you share your config file, maybe it'd be easier to see what you're trying to achieve.

michaelhue commented 5 years ago

Hey, thanks for the reply! Correct, there are meta tags with an empty "content" attribute in the final output. Here is an example:

return [
    'defaultMeta' => [
        'theme-color' => ['meta.appThemeColor'],
    ],
];

The meta.appThemeColor field is a global color field. If the field has no value, it returns an empty string. The resulting meta tag is: <meta name="theme-color" content="">.

In my opinion the plugin should ignore the meta tag if it's value is an empty string.

aelvan commented 5 years ago

Right. This was actually intentional, but after some deliberation, we've decided to change the default output template to not output tags with an empty value, it'll be in the next tagged release. This can (and could) still be overridden by customizing the output template.