Mobile app version of vmapp.org
Login or Join
Kevin317

: How to handle 404's in GitHub Pages while using Jekyll? I've setup my site at GitHub using Jekyll framework. I've a problem with 404's. I added a 404.html and it is working well for some

@Kevin317

Posted in: #Github #Jekyll

I've setup my site at GitHub using Jekyll framework. I've a problem with 404's. I added a 404.html and it is working well for some typos. But, since in Jekyll categories are rendered in a separate directories and when a user is trying to access the URL like example.com/category/ it shows the GitHub's 404 instead of my custom 404.html and also I don't want to index the category so what can I do?

P.S: Added a index.html to each and every category is a good idea. But, while building it overwrites everything in Jekyll.

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Kevin317

2 Comments

Sorted by latest first Latest Oldest Best

 

@Cugini213

GitHub allows you to create a custom 404 page but there is a caveat. The 404 will be displayed only if you use a custom domain or for user pages.


Custom 404s only work when they are served from the root of a Pages domain, for example a project using a custom domain or a user pages repository. A custom 404 page on project pages that are not using a custom domain will not work


In other words, the 404 error page will not work for project pages with no custom domain.

In your case, it looks like you are using a custom domain thus the limitation may not apply to you. Are you sure your 404 is working correctly and you don't have an issue elsewhere?

Just to show you an example, in our company blog we use Jekyll, we host the page on GitHub pages and we have a custom 404 error page. As you can see, it also works on a subfolder.

Try to visit this page
blog.dnsimple.com/2011/invalid

and you can check yourself. If it helps you to debug, the pages are generated directly by GitHub. We have another repository where we publish the HTML pages to GitHub (instead of a Jekyll powered website), I should check if in that case it also works.

10% popularity Vote Up Vote Down


 

@BetL925

According to the GitHub documentation on custom 404s you are out of luck:


Custom 404s only work when they are served from the root of a Pages domain, for example a project using a custom domain or a user pages repository.


It looks like sub-folders are not supported. Only the root folder.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme