简体   繁体   English

如何修复在 GitHub 页面上导入 css 的 404 错误?

[英]How can I fix 404 error importing css on GitHub Pages?

I currently have the following Git Repository: https://github.com/SebastianGode/ansible-collection-cloud/tree/gh-pages And the GitHub Page link: https://sebastiangode.github.io/ansible-collection-cloud/ I currently have the following Git Repository: https://github.com/SebastianGode/ansible-collection-cloud/tree/gh-pages And the GitHub Page link: https://sebastiangode.github.io/ansible-collection-cloud /

The problem is that GitHub Pages will only solve the index.html and will throw an 404 for all required css and image stuff:问题是 GitHub 页面只会解决 index.html 并且会为所有必需的 css 和图像内容抛出 404: 在此处输入图像描述

As the documentation is getting automatically generated by a travis-ci pipeline it's probably impossible to change paths, but as it works when hosted it locally it also should work on GitHub pages.由于文档是由 travis-ci 管道自动生成的,因此可能无法更改路径,但由于它在本地托管时可以工作,因此它也应该在 GitHub 页面上工作。

Is there any solution to this problem?这个问题有什么解决办法吗?

I fixed it.我修好了它。

GitHub has Jekyll running behind it which will mess up special paths (here the underscore paths). GitHub 后面有 Jekyll 运行,这会弄乱特殊路径(这里是下划线路径)。 You can disable jekyll by just creating a .nojekyll file in the root directory of the branch.您可以通过在分支的根目录中创建一个.nojekyll文件来禁用 jekyll。 If you use travis-CI for something like that and run a tox script just call the command touch {toxinidir}/.nojekyll如果你使用 travis-CI 来做类似的事情并运行一个 tox 脚本,只需调用命令touch {toxinidir}/.nojekyll

This will result in a working website for me.这将为我提供一个工作网站。

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

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