V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
azicat
V2EX  ›  问与答

[求教] hexo 搭建 github pages 报 404

  •  
  •   azicat · 2018-11-15 10:53:39 +08:00 · 1941 次点击
    这是一个创建于 1982 天前的主题,其中的信息可能已经有所发展或是发生改变。
    本地预览正常,hexo d -g 后把整个 Hexo 根目录下的文件 push 了,请教一下大家这种情况怎么解决,在不重装的前提下。
    地址: https://github.com/F8F-1BearCat/F8F-1BearCat.github.io
    第 1 条附言  ·  2018-11-15 13:19:19 +08:00

    _config.yml中deploy配置

    deploy:
        type: git
        repository: [email protected]:F8F-1BearCat/F8F-1BearCat.github.io.git
        branch: master
    
    第 2 条附言  ·  2018-11-15 13:26:24 +08:00

    @Trim21 日志有外链没回复成功,只能append了,执行 hexo d -g 后部分日志:

    [master ed065cc] Site updated: 2018-11-15 11:24:45
     505 files changed, 9636 insertions(+), 4680 deletions(-)
     rewrite db.json (100%)
     create mode 100644 node_modules/balanced-match/README.md
     create mode 100644 node_modules/brace-expansion/README.md
     create mode 100644 node_modules/decode-uri-component/readme.md
     create mode 100644 node_modules/hexo-deployer-git/node_modules/swig/HISTORY.md
     create mode 100644 node_modules/hexo-deployer-heroku/node_modules/swig/HISTORY.md
     create mode 100644 node_modules/hexo-deployer-openshift/node_modules/swig/HISTORY.md
     create mode 100644 node_modules/hexo-deployer-openshift/node_modules/swig/README.md
     create mode 100644 node_modules/hexo-deployer-rsync/README.md
     create mode 100644 node_modules/hexo-front-matter/README.md
     create mode 100644 node_modules/hexo-generator-archive/README.md
     create mode 100644 node_modules/hexo-generator-category/README.md
     create mode 100644 node_modules/hexo-generator-index/README.md
     create mode 100644 node_modules/hexo-generator-tag/README.md
     create mode 100644 node_modules/hexo-renderer-ejs/README.md
     create mode 100644 node_modules/hexo-renderer-marked/README.md
     create mode 100644 node_modules/hexo-renderer-stylus/README.md
     create mode 100644 node_modules/hexo/node_modules/hexo-cli/assets/themes/landscape/README.md
     create mode 100644 node_modules/nunjucks/CHANGELOG.md
     create mode 100644 node_modules/swig-templates/HISTORY.md
    warning: LF will be replaced by CRLF in public/css/main.css.
    The file will have its original line endings in your working directory.
    Branch master set up to track remote branch master from [email protected]:F8F-1BearCat/F8F-1BearCat.github.io.git.
    To [email protected]:F8F-1BearCat/F8F-1BearCat.github.io.git
       0d4c1c3..ed065cc  HEAD -> master
    INFO  Deploy done: git
    
    11 条回复    2018-11-15 14:10:14 +08:00
    huaxianyan
        1
    huaxianyan  
       2018-11-15 10:55:29 +08:00
    你可以直接进 public 然后用 git 自己的 push
    azicat
        2
    azicat  
    OP
       2018-11-15 11:09:18 +08:00
    @huaxianyan 操作之后还是不行
    azicat
        3
    azicat  
    OP
       2018-11-15 11:12:15 +08:00
    @huaxianyan 而且如果这样可以的话,每次 hexo d 之后都要再重新 push ?
    Trim21
        4
    Trim21  
       2018-11-15 11:15:39 +08:00 via Android
    贴一下 log
    azicat
        5
    azicat  
    OP
       2018-11-15 11:29:28 +08:00
    我删掉 node_modules/重新 install,再执行 hexo d -g 后邮件收到了 build 错误
    GitHub <[email protected]>
    今天, 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
        6
    anubu  
       2018-11-15 11:58:01 +08:00
    似乎是把仓库搞混了,如果你贴的仓库地址就是你要的 git page 仓库,那它应该存放的是 public 目录下的内容而不是整个 hexo 程序目录。
    可以这么理解 hexo 目录下为源代码和编译程序,public 目录下为编译后的制品。其实就是静态页面生成器和静态页面的关系。你需要做的是把静态页面放到 git pages 仓库中。
    报 404 的直接原因是你的 git pages 仓库下没有 index.html 这个文件。
    jingyulong
        7
    jingyulong  
       2018-11-15 12:06:48 +08:00
    我只用过 jelly,感觉你应该只把 publish 里面的内容提交上来
    verrickt
        8
    verrickt  
       2018-11-15 12:42:48 +08:00 via Android
    我记得我是用的 hexo git deployer。
    config.yml 填好后 hexo d 就可以了
    我看你的 git 仓库里似乎文件结构不太对,多了几个文件夹。里面的内容应该直接是 deploy 里的才对
    你可以参考下我的 https://github.com/Verrickt/verrickt.github.io
    azicat
        9
    azicat  
    OP
       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
        10
    azicat  
    OP
       2018-11-15 13:27:00 +08:00
    @Trim21 日志 append 了
    azicat
        11
    azicat  
    OP
       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
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2771 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 12:27 · PVG 20:27 · LAX 05:27 · JFK 08:27
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.