No trailing slash just fine on GitHub Pages, but eternal redirect locally

Hello,

For the website of AntennaPod we have a Privacy page:

On our live site (hosted via GitHub Pages) it is accessible without trailing slash (= pretty). A redirect file makes sure that the page is accessible also with trailing slash: antennapod.github.io/privacy-redirect.md at master · AntennaPod/antennapod.github.io · GitHub

However, when building the site locally (bundle exec jekyll sve --watch), this somehow leads to an eternal redirect – you never actually land on the privacy page. The same for the ‘documentation’ collection.

This can be fixed by just having the trailing slash. But I would prefer not to, for aesthetic reasons.

Would anyone have an idea why this eternal redirect might be happening locally? (And how we can avoid it locally, without enforcing trailing slashes on our live site?)

I suspect the issue is due to subtle differences in request handling between Github’s server and WebBrick (the server Jekyll uses for local development).

One workaround is to exclude the pseudo-redirect when developing locally. For example, if you add a _local_config.yml file with an overriding exclude:

exclude:
  - privacy-redirect.md
  - .sass-cache/
  - ...

Then run Jekyll’s server with the chained configs:

bundle exec jekyll serve --config _config.yml,_local_config.yml

Probably you could flip this and have a _prod_config.yml to include privacy-redirect.md, but only use it in the Workflow for building the production site. Then local development wouldn’t need extra arguments.

1 Like