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
165 stars 70 forks source link

Meta tags generated by SEOMatic sometimes contains IP addresses #1432

Closed obrassard closed 6 months ago

obrassard commented 6 months ago

Question

Hello, I hope you are doing great!

Our team relies on SEOmatic to generate meta tags and sitemaps for our Craft website, which is hosted on AWS in an ECS container. We use Cloudfront for caching purposes to optimize performance.

Recently, we've observed anomalies in Google Search Console. Indeed, it seems that Google is selecting IP addresses as canonical URLs for certain pages instead of the correct domain URLs. Additionally, some indexed pages are referencing IP addresses in the 'Referring Page' field.

During our investigation, we discovered that certain pages cached by Cloudfront contained IP addresses directly within meta tags in the DOM. This led us to suspect that the issue might be related to our SEOmatic configuration.

However, upon manual inspection of the pages and site maps, most of the time URLs generated by SEOmatic appear to be correct. Therefore, we're trying to understand the circumstances under which an IP address is being generated instead of the proper URL. We suspect that the incorrect meta-tags or sitemaps might be generated when making a new deployment on ECS.

Do you have any other idea what might be causing this problem? We would greatly appreciate any insights you can provide to help us resolve this issue !

Thank you

Additional context

Here's an example of a page with of an incorrect canonical URL on Google Search Console (in French):

431215530_1123784522087942_869019329334696604_n

obrassard commented 6 months ago

In order to better diagnose the problem, we disabled these two parameters:

'regenerateSitemapsAutomatically' => false,
'submitSitemaps' => false,

When regenerateSitemapsAutomatically is deactivated, how can site maps be regenerated manually? Also, is there a way to submit site maps manually from within the plugin?

Thanks

khalwat commented 6 months ago

If I had to guess, probably you are not properly setting your site's site URL, as discussed here:

https://craftcms.com/docs/4.x/sites.html#site-url

If your site URL is not set properly, Yii2/Craft will attempt to determine it, and may end up falling back on the IP address.

obrassard commented 6 months ago

@khalwat All sites URLs are configured using an environment variable. We are not using @web alias in our configuration.

khalwat commented 6 months ago

Well, something is causing it to resolve to an IP address. SEOmatic just asks Craft what the site URL is when generating any of the sitemaps or meta tags that it generates.

So the source of the problem -- somehow -- is upstream from SEOmatic.

It wouldn't have anything to do with sitemap submission to Google, and sitemaps and meta tags are generated when pages are requested -- and then they are cached using whatever your default caching mechanism is.

I wish I had a more solid answer for you, and I'm happy to continue this discussion if it does end up that SEOmatic is somehow at fault -- but I'm rather certain it's going to be a devops issue of some form or another.

obrassard commented 6 months ago

Ok thank you for your help, we will continue investigating with that in mind.

Just one last question: what is the behaviour of the plugin when regenerateSitemapsAutomatically is disabled ? And is there a way to regenerate site maps manually when it is disabled ?

khalwat commented 6 months ago

If you have regenerateSitemapsAutomatically disabled, it will not regenerate the sitemap when content authors make changes.

You will need to manually regenerate it with the CLI command:

https://nystudio107.com/docs/seomatic/configuring/content-seo.html#sitemap-generation