简体   繁体   English

如何在使用Jekyll时在GitHub页面中处理404

[英]How to handle 404's in GitHub Pages while using Jekyll

I've setup my site at GitHub using Jekyll framework. 我使用Jekyll框架在GitHub上设置了我的网站。 I've a problem with 404's. 我有404的问题。 I added a 404.html and it is working well for some typos. 我添加了一个404.html,它适用于一些拼写错误。 But, since in Jekyll categories are rendered in a separate directories and when a user is trying to access the url like www.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? 但是,因为在Jekyll类别中呈现在一个单独的目录中,当用户试图访问网址时,例如www.example.com/category/它显示GitHub的404而不是我的自定义404.html,我也不想要索引类别,我该怎么办?

PS: Added a index.html to each and every category is a good idea. PS:为每个类别添加了index.html是个好主意。 But, while building it overwrites everything in Jekyll. 但是,在建造它时会覆盖杰基尔的一切。 Any tips about that? 有关于此的任何提示?

This is very late, but I just solved this problem myself and want to help anyone who sees this question later, so the answer is just to put the following snippet: 这已经很晚了,但我自己刚刚解决了这个问题,想要帮助后来看到这个问题的人,所以答案只是放下以下片段:

permalink: /404.html

in your 404 page's YAML frontmatter. 在你的404页面的YAML前沿。 This tells Jekyll to put the 404 page at that location, where it's automatically recognized as a 404 page. 这告诉Jekyll将404页面放在该位置,它自动被识别为404页面。

Is your site domain pointing at 108.162.199.32 ? 您的网站域名是否指向108.162.199.32 Try pointing at 192.30.252.153 , 192.30.252.154 . 尝试指着192.30.252.153192.30.252.154

Hope this fixes your problem :-) 希望这可以解决你的问题:-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM