urlyamljekyllconfiggithub-pages

Trailing slashes in Jekyll + GitHub Pages site cause 404


Edit 7/13/2024: My site no longer uses GitHub Pages.

I would like all of the following URLs to resolve on my website, which is built with Jekyll and hosted on GitHub Pages:

Locally they all work correctly, but right now on the live site, the first and third option resolve, but the middle one with the trailing slash causes a 404 error.

I am not using permalinks at the moment. When I do add permalink: /about/ to the front matter in my page, the trailing slash issue is resolved, but then about.html does a 404. I suppose that's better than the current behavior but I'd prefer if all three options worked individually or redirected to one that does.

If it's relevant, I set a canonical reference in the <head> of my layout template like so:

<link rel="canonical" href="{{ site.url }}{{ page.url | replace:'index.html',''}}">

And here is my my _site's file tree:

enter image description here


Solution

  • According to support at GitHub this is expected behavior in GitHub Pages:

    Hello Michael,

    Thanks for contacting GitHub Support with your questions about GitHub Pages.

    There's is currently no way to change our trailing slash behavior at this time, though I do understand that a situation like this can be quite frustrating.

    I'll share your use case with the team for consideration in future improvements. I can't say if or when a change will happen, but your feedback is in the right hands.

    Thanks,

    Steve @slgraff GitHub Support