Custom routes with error "ERR_TOO_MANY_REDIRECTS"

I am working on a study site and for each subject there will be a reading plan with the link structure: /plans/name-plan/{slug}/.

In /plans/plan-name/ all contents related to the reading plane in question will be displayed, while in /plans/ all available reading planes will be displayed using their own template (plans-name.hbs).

For this I configure my routes.yaml like this:

  /planos/: plans
  /planos/os-tesouros-salmo-119/: plans-psalm-119
  /planos/evangelho-de-joao/: plans-john
  /planos/malaquias-hoje/: plans-malachi

    permalink: /planos/malaquias-hoje/{slug}/
    filter: 'tag:malaquias-hoje'
    template: plans-malachi
    rss: false

    permalink: /planos/os-tesouros-salmo-119/{slug}/
    filter: 'tag:os-tesouros-do-salmo-119'
    template: plans-psalm-119
    rss: false

    permalink: /planos/evangelho-de-joao/{slug}/
    filter: 'tag:evangelho-de-joao'
    template: plans-john
    rss: false

    permalink: /{slug}/
    template: index

  tag: /{slug}/
  author: /autor/{slug}/

As in routes.yaml I have defined that the permalink of the tag will be only /{slug}/ in redirects.json I direct the tags corresponding to the plan to your own page

    "from": "/os-tesouros-do-salmo-119/" ,
    "to":  "/planos/os-tesouros-salmo-119/",
    "permanent": true
    "from": "/evangelho-de-joao/" ,
    "to":  "/planos/evangelho-de-joao/",
    "permanent": true
    "from": "/malaquias-hoje/" ,
    "to":  "/planos/malaquias-hoje/",
    "permanent": true

But the only plan that works correctly is /planos/os-tesouros-salmo-119/ (who was the first to be created) all the others when I try to access the main page of the plan (/plans/plan-name/) returns the error "ERR_TOO_MANY_REDIRECTS".

And the generated url is like this:



Development Environment localhost
Ghost Version: 2.25.6

I think the first problem is probably that you’ve missed this detail from the docs:

And don’t forget: will now also be redirected to — so no duplicate content!

Focusing just on the tag os-tesouros-do-salmo-119:

  • You’ve already change the tag page name to be just /os-tesouros-do-salmo-119/, by editing the taxonomy config.
  • Then you’ve changed the URL again by creating a collection referencing that tag at /planos/os-tesouros-salmo-119/. So with this config /os-tesouros-salmo-119/ redirects to /planos/os-tesouros-salmo-119/.
  • Then you’ve overwritten that again, by creating a route at /planos/os-tesouros-salmo-119/: plans-psalm-119
  • And finally you’ve duplicated the redirect from /os-tesouros-salmo-119/ to /planos/os-tesouros-salmo-119/

I’m not surprised Ghost is confused, I am!!! I’m surprised this route works.

So, to move forward… I recommend stripping this configuration right back to the bare minimum and take it step-by-step to understand what each piece of config does.

I’m not 100% on what you want exactly - if all tags represent plans, then you probably don’t even need collections, you could change the tag taxonomy URL to be /planos/:slug/, unless you’re dead set on custom template names.

For definite:

  • Remove the redirects, they are not needed.
  • Remove the routes that match collections I don’t think you need those either, it seems like you just want the collections?
  • maybe temporarily revert the taxonomy name change, to make sure that isn’t causing conflicts.

Do you have a tag, post or page in the system that is called “planos” ?

1 Like