本文介绍了Jekyll + GitHub Pages网站中的尾部斜杠导致404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在我的网站(由Jekyll构建并托管在GitHub页面)上解析以下所有URL:




  • 解决方案

    根据GitHub的支持,这是GitHub页面中的预期行为:


    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:

    解决方案

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

    这篇关于Jekyll + GitHub Pages网站中的尾部斜杠导致404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 04:31