WithCandour / statamic-aardvark-seo

Candour's SEO addon for Statamic
https://statamic.com/marketplace/addons/aardvark-seo
11 stars 18 forks source link

Sitemap no absolute URLs #89

Closed LorensoD closed 3 years ago

LorensoD commented 3 years ago

How is it possible that my automatically generated sitemap contains URLs without the domain?

image

https://eventix.io/sitemap_help_pages.xml

AndrewHaine commented 3 years ago

Hi @LorensoD ,

Thank you for reporting, has the Canonical URL been overridden for the pages which aren't producing absolute URLs?

In the eventix sitemap it looks like the pages which aren't generating absolute links are duplicates of other entries, I'm wondering whether it may be that the URL in the canonical field is simply a relative URL.

I'll get a fix in place to ensure that the canonical URLs we're pulling in are transformed to be absolute before putting them in the Sitemap.

AndrewHaine commented 3 years ago

This should now have been fixed in 2.0.12 :)

LorensoD commented 3 years ago

Doesn't seem to fix my issue 🤔.

The Canonical URL has not been overridden for those pages. But interestingly enough. When I change the Canonical URL of a duplicate page the following occurs:

image I changed the Canonical URL of the page to /help/create-scanner-login-test.

Do I maybe need to completely regenerate my sitemaps? And if yes, how do I achieve this?

AndrewHaine commented 3 years ago

Hi @LorensoD ,

The sitemap can be regenerated by refreshing the cache (php please cache:clear), that would be my first thought, could I also check that all the sites that are in Statamic have full URLs in the config (e.g. 'https://eventix.io' or 'http://127.0.0.1:8000') rather than just '/'.

I don't think the above is required as the absoluteUrl() function on the Statamic Site object does fall back to using the request data (as seen here), but it's still worth checking as this is my next thought on what could be causing this.

LorensoD commented 3 years ago

Hi @AndrewHaine,

Thanks for your message! I've checked my sites.php and it seems that every site has a full URL.

AndrewHaine commented 3 years ago

Hi @LorensoD ,

I've been testing my local site this week and I'm still unable to replicate any non-absolute URLs appearing in the sitemaps, would it be possible for me to get read-only access to your repo in order to ensure my testing conditions are identical to what you're working with?

Thanks, Andrew

AndrewHaine commented 3 years ago

Hi @LorensoD ,

Thank you for sending me access to the site, I've identified the issue as being to do with entries which are redirect pages. Statamic was giving us a non-absolute value as a result of getting the redirect URL.

The fix I've applied is to filter out any entries which are redirect pages as it's best that they don't get placed in the sitemap.

The latest release (2.0.14) contains this fix :)

Thanks, Andrew

LorensoD commented 3 years ago

Hi @AndrewHaine,

I can confirm that this fix works and solves my issue. 🎉 Thanks for your help!