vaersaagod/seomate

Replace empty meta values with null

Closed this issue · 3 comments

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.

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.

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.

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.