Google indexing 'Page with redirect' for every page on Gatsby site

I’ve recently deployed this site. It uses Gatsby 5.0. Trailing slashes on by default.

Netlify site name: myndful-9772dafe.netlify.app

Google search console is now showing a ‘Page with redirect’ indexing error for every page on the site.

Working properly:

  • URLs on the apex domain, with a trailing slash are indexed correctly

Pages with a problem:

  • URLs on the apex domain, witih no trailing slash are all shown as ‘page with redirect’
  • URLs for the www. subdomain, and no trailing slash, are also shown as ‘page with redirect’

Sitemap includes only urls on the apex domain, with a trailing slash.

All the sub-pages in the ‘blog’, ‘therapy’ and ‘team’ directories are generated using createPage().
However I am seeing this problem for all of the pages generated via createPage() as well as all other pages on the site.

How can I get rid of all these ‘page with redirect’ errors?

There are numerous threads on the forums about redirects and trailing slash. Netlify documentation also mentions trailing slash

Our CDN edge nodes do URL normalization before the redirect rules kick in.

If the framework builds files in /[page-name]/index.html rather than /[page-name].html then URLs are treated as /[page-name]/ as opposed to /[page-name]. Thus, redirects will automatically occur.

URLs on the www subdomain will always redirect to the apex when the apex is the primary. (This also happens vice versa when the www is primary domain.) To avoid issues here, decide what domain to use (apex or www) and stick to it when it is printed on letterheads, business cards, added to analytics platforms, social media profiles, etc.

When linking to pages within the site, make sure the pathnames follow the appropriate structure (with-/out trailing slash) as outlined above. If a sitemap exists, make sure the URLs are also in the same format.

Further reading

Hi Thanks for getting back to me.

I’ve read a lot of the articles etc on trailing slashes. I understand the issues with trailing slashes and why a redirect is necessary.
However what is important for me to know, for SEO is:

  • How can I get rid of all the ‘page with redirect’ errors in the google search console?
    I previously hosted a site on Squarespace, which redirects all the urls with trailing slash to non-trailing slash urls.
    This did not create ‘page with redirect’ errors in the google search console

  • It’s unclear if the ‘pretty urls’ option will change the way these redirects look to Google, will enabling this option help?

Kind regards
Roger

Best to ask someone that works for Google about this.

As mentioned in my previous post, if the page/directory structure is /[path]/index.html and not /[path].html, a trailing slash is alway present.

For example, say you have an About page. If the file in the project output directory (and publish directory) is

/about/index.html

then the path will always have a trailing slash i.e.

https://example.com/about/

If the file in the output directory is

/about.html

then the path will not have a trailing slash i.e.

https://example.com/about

This is mentioned in the support guide linked previously as a quote …good rule of thumb.

Thanks Jasiqli,

However the behaviour you mention for directories vs files does not match what I’m seeing.
For example i have a file at /faq.js which Gatsby generates as /faq/ and there is a redirect from /faq to /faq/

That is exactly the behaviour I mentioned.

You mentioned it for a directory, not for individual files

Also can you please answer my question on whether the ‘pretty urls’ feature will change this behaviour?
IE will it change whether google will see the /faq page as a redirect to /faq/ ?

@roger1,

Please don’t create duplicate posts in the helpdesk and the forums (or mention if you do, so we can respond in one place instead of having two different conversations).

I have inlined my response from the helpdesk:

As far as I can see, both the redirects mentioned here:

  • URLs on the apex domain, witih no trailing slash are all shown as ‘page with redirect’

  • URLs for the www. subdomain, and no trailing slash, are also shown as ‘page with redirect’

are expected. Here’s why:

You’ve pretty URLs turned on (which is most probably the default):

You need to disable it to disable the redirection from non-trailing slash to trailing slash. You can do that by going to: your asset optimization settings: Netlify App

  1. Click on Edit settings
  2. → Enable asset optimization
  3. → Uncheck all
  4. → Save
  5. → Edit settings (again)
  6. → Disable asset optimization
  7. → Save

As for the www. redirecting, that’s expected as per:

This cannot be disabled.

But I believe the ideal solution here is to add meta canonical tags: How to Specify a Canonical with rel="canonical" and Other Methods | Google Search Central  |  Documentation  |  Google for Developers

also, to answer this question:

Even if you have a file faq.js, Gatsby renders it as /faq/. We don’t, or can’t really compare with your source code. For us, when you deployed it, it’s a directory and not a file.

I have checked my settings, I don’t have any asset optimisation switched on.

Also, reading the description for Pretty URLs, it is described as a rewrite.
Is it a redirect or a rewrite?

Hi @roger1 ,

I can confirm pretty urls are enabled on the site and following the steps that Hrishikesh shared :point_up: should disable pretty urls.

Also, reading the description for Pretty URLs, it is described as a rewrite.
Is it a redirect or a rewrite?

Pretty URLs in Netlify can be considered as rewrites. When you enable the Pretty URLs feature in Site settings > Build & deploy > Post processing > Asset optimization , it rewrites paths like /about.html to /about/ without changing the URL in the visitor’s address bar. This is similar to a rewrite with a 200 status code

Hi Audrey,
Thanks for clarifying.

The Asset Optimization settings in my Netlify account for the site indicates that Asset Optimization is switched off but you’re indicating it is actually switched on - This is confusing.
Does this mean that all asset optimizations are actually switched on by default?

Also, the response from Hrishikesh is confusing, since the user interface uses the term rewrite, and the question I have is related to redirects.
Rewrite and Redirect are both different things, and this difference is important from a Google indexing and SEO perspective.

I will try disabling Pretty URLs as suggested and see if that fixes the issue.

Kind regards
Roger

Hi Roger,

Asset optimization setting has an option to enable/disable all settings with a single control. Yet, pretty URLs isn’t affected by that control, which made the interaction very unintuitive and confusing!

Today, we’ve removed pretty URLs setting from the Asset optimization card and we added a new dedicated section for it so you wouldn’t need to go through the steps shared :point_up: to disable pretty URLs going forward.

Apologies for the confusion and hope that helps!

Hi Audrey,

Thanks for taking on my feedback, I’m glad it could be used to improve the site.
I’ve had a look and the change looks good, it’s much clearer and more intuitive now.

I am going to leave pretty URLs switched on for now. I need redirects in place for the non-slash paths since these are referenced in external sites.

I’ve also followed up on this issue with Google.
The feedback I’ve received so far is that these additional paths are not affecting SEO ranking.
However they have made some suggestions for how I can reconfigure my search console settings to remove the www.* paths from being reported, which I’ve done and am just waiting on google to re-crawl the site to see if their suggestion has changed the results.

Have you had any reports of this issue from other Netlify users?

Kind regards
Roger