[求教] hexo 搭建 github pages 报 404

2018-11-15 10:53:39 +08:00
 azicat
本地预览正常,hexo d -g 后把整个 Hexo 根目录下的文件 push 了,请教一下大家这种情况怎么解决,在不重装的前提下。
地址: https://github.com/F8F-1BearCat/F8F-1BearCat.github.io
1944 次点击
所在节点    问与答
11 条回复
huaxianyan
2018-11-15 10:55:29 +08:00
你可以直接进 public 然后用 git 自己的 push
azicat
2018-11-15 11:09:18 +08:00
@huaxianyan 操作之后还是不行
azicat
2018-11-15 11:12:15 +08:00
@huaxianyan 而且如果这样可以的话,每次 hexo d 之后都要再重新 push ?
Trim21
2018-11-15 11:15:39 +08:00
贴一下 log
azicat
2018-11-15 11:29:28 +08:00
我删掉 node_modules/重新 install,再执行 hexo d -g 后邮件收到了 build 错误
GitHub <support@github.com>
今天, 3:26 你
The page build failed for the `master` branch with the following error:

There is a syntax error in the 'for' loop on line 118 of `node_modules/hexo-deployer-git/node_modules/swig/HISTORY.md`. Valid syntax is 'for <item> in <collection>', and the <item> variable may not contain hyphens or quotation marks. For more information, see https://help.github.com/articles/page-build-failed-syntax-error-in-for-loop/.
anubu
2018-11-15 11:58:01 +08:00
似乎是把仓库搞混了,如果你贴的仓库地址就是你要的 git page 仓库,那它应该存放的是 public 目录下的内容而不是整个 hexo 程序目录。
可以这么理解 hexo 目录下为源代码和编译程序,public 目录下为编译后的制品。其实就是静态页面生成器和静态页面的关系。你需要做的是把静态页面放到 git pages 仓库中。
报 404 的直接原因是你的 git pages 仓库下没有 index.html 这个文件。
jingyulong
2018-11-15 12:06:48 +08:00
我只用过 jelly,感觉你应该只把 publish 里面的内容提交上来
verrickt
2018-11-15 12:42:48 +08:00
我记得我是用的 hexo git deployer。
config.yml 填好后 hexo d 就可以了
我看你的 git 仓库里似乎文件结构不太对,多了几个文件夹。里面的内容应该直接是 deploy 里的才对
你可以参考下我的 https://github.com/Verrickt/verrickt.github.io
azicat
2018-11-15 13:22:43 +08:00
@anubu
@verrickt 我也注意到应该只提交 public 文件目录下的内容,public 目录下是有 index.xmld 的,但是我执行了 hexo d -g 后整个根目录下的都 push 掉了,看到这个帖子里面也有相同的问题,重装问题不复现了 https://www.v2ex.com/t/275466
azicat
2018-11-15 13:27:00 +08:00
@Trim21 日志 append 了
azicat
2018-11-15 14:10:14 +08:00
删除.deploy_git 文件夹并且执行 hexo clean 后,再重新执行 hexo d 就可以了。多谢各位的解答,以及下面这篇博客的贡献者。
https://xuanwo.org/2014/08/14/hexo-usual-problem/#deploy%E4%B9%8B%E5%90%8E-%E9%A1%B5%E9%9D%A2%E9%95%BF%E6%97%B6%E9%97%B4404

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/508052

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX