V5.x collections AMP post --> redirect error

self hosted on DO
Ghost version: 5.5
Node version: 14.19.3
db: mysql
ghost doctor identifies no errors

After upgrade to v5.x amp versions of urls in routes.yaml > collections causes an ugly browser error: “The page isn’t redirecting properly”. The inspector tools network tab show a long chain of 301 redirects to the same url. Presumably it just times out.

from routes.yaml:

    permalink: /docs/{slug}/
    filter: primary_tag:docs
    data: tag.docs
    template: tag

    permalink: /{slug}/

Amp url from collection that causes redirect error: https://lexchart.com/docs/account/amp/
Non-amp version of same collection url returns 200: https://lexchart.com/docs/account/
Amp version of post NOT in collection returns 200: https://lexchart.com/private-equity-energy-fund/amp/
Non-amp version of same post NOT in collection returns 200: https://lexchart.com/private-equity-energy-fund/

I would like the amp urls for posts in collections to return a 200 code and load properly. Any guidance?


:thinking: I’m not sure what would’ve changed in v5 to cause this error.

Do you have any redirects set up in addition to your routes?

I should have been more precise. I do not necessarily attribute the issue to v5. Rather, I did not experience the issue prior to v5, and do experience it after v5. The source could be something else.

The redirects.json file contains one redirect for a specific post, so I do not think that is the issue.

To anticipate a follow up, no there are no redirect rules in NGINX except for http → https, and www. → non-www. Those have been in place since day one.

I’d appreciate any suggestions. Thanks!

Any suggestions @RyanF?

Sorry not to have responded sooner.

Give the info here, I wasn’t able to replicate this issue.

  • Do you have any routes set up in addition to the collections?
  • Have you tried restarting Ghost?

@RyanF Hi Ryan, after lots of testing and experimentation, I have finally isolated the cause of this error.

Two conditions must be true:

  1. Set up a collection with a permalink, like this:
        permalink: /docs/{slug}/
        filter: primary_tag:docs
        data: tag.docs
        template: tag
  1. Modify the tag taxonomy to use the tag slug, like this:
  tag: /{slug}/
  author: /author/{slug}/

when you navigate to /docs/some-article/amp/, the inspector shows a long series of 301 redirects and then stops with this message in the browser: “The page isn’t redirecting properly.”

Yes, adding `/tag/’ or ‘/topic/’ to the tag taxonomy route resolves the issue. However, it is removed for a reason. Adding it back would require a lot of redirect logic.

Any way to resolve this?

Nice research! Let me dig into this and let you know if I can find anything more.

Any update on mark.I’s issues, because i am also getting similar issues.

Any update on when this might be resolved? It is a chronic issue with Google indexing in the search console. Ghost pages generally do quite well but this causes a failure.

I was never able to replicate this issue. However, I think that there’s a conflict being created in the routing: there are two routes at /docs/. This conflict is likely causing unexpected behavior. That would also explain why adding the /tag/ or /topics/ back in helps to alleviate the issue.

Alternatively, you could try changing the /docs/ collection to something else, to avoid the conflict at that point.