Hugo GitHub Action 部署没有 index.html - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
请不要在回答技术问题时复制粘贴 AI 生成的内容
Reid
V2EX    程序员

Hugo GitHub Action 部署没有 index.html

  •  
  •   Reid 2022-06-06 16:05:17 +08:00 1967 次点击
    这是一个创建于 1227 天前的主题,其中的信息可能已经有所发展或是发生改变。

    参考这篇文章部署了 Hugo ,https://www.fournoas.com/posts/deploy-hugo-site-using-github-actions/ 单独 Public 上传之后,https://reid00.github.io/ 可以正常访问, 但是 用 Github Action 之后发现个人主页变成了 index.xml 的形式 查看直接和 public 里面比,少了很多东西 各位彦祖,有知道怎么回事的吗?

    name: Deploy Hugo Site to Github Pages on Main Branch on: push: branches: - main jobs: build-deploy: runs-on: ubuntu-latest steps: - name: Check out repository code uses: actions/checkout@v3 - name: Setup Hugo uses: peaceiris/actions-hugo@v2 with: hugo-version: latest # 这里的版本号要与你安装的版本号一致 extended: true - name: Build run: hugo --minify - name: Deploy uses: peaceiris/actions-gh-pages@v3 with: deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }} # 这里的 ACTIONS_DEPLOY_KEY 则是上面设置 Private Key 的变量名 external_repository: Reid00/Reid00.github.io # Pages 远程仓库 publish_dir: "./public" keep_files: false # remove existing files publish_branch: main # deploying branch commit_message: ${{ github.event.head_commit.message }} 
    hwdef
        1
    hwdef  
       2022-06-06 16:33:27 +08:00
    跟你执行的时候加了 --minify 参数有关吗
    istevenshen
        2
    istevenshen  
       2022-06-06 16:36:50 +08:00
    你指定 hugo 版本看看,如 hugo-version: '0.59.0',我也用的是 peaceiris/actions-gh-pages@v3 ,貌似一直都没什么问题
    Reid
        3
    Reid  
    OP
       2022-06-06 16:36:54 +08:00
    @hwdef 应该没关系,我刚刚更新了下试了下,不行,index.html 好多东西没有部署到 github pages 那个仓库
    istevenshen
        4
    istevenshen  
       2022-06-06 16:38:09 +08:00
    peaceiris/actions-hugo@v2
    istevenshen
        5
    istevenshen  
       2022-06-06 16:43:25 +08:00
    还有一个就是如果你使用了 themes ,记得要获取 submodule 主题,有时候 theme 目录空了也会导致个人主页变成了 index.xml
    Reid
        6
    Reid  
    OP
       2022-06-06 16:44:24 +08:00
    @istevenshen 也不太行,我之前试过,刚刚又更新了下 试了下。这个问题 搞了两天了...
    Reid
        7
    Reid  
    OP
       2022-06-06 16:50:54 +08:00
    @istevenshen public 了 source 仓库 https://github.com/Reid00/Reid00.github.io.source
    你这个方法,我刚刚加上了,我看看怎么解决这个 error
    istevenshen
        8
    istevenshen  
       2022-06-06 16:54:32 +08:00
    调整一下 jobs

    ```
    jobs:
    deploy:
    runs-on: ubuntu-20.04 # 在什么环境运行任务
    steps:
    - uses: actions/[email protected] # 引用 actions/checkout 这个 action ,与所在的 github 仓库同名
    with:
    submodules: true # Fetch Hugo themes (true OR recursive) 获取 submodule 主题
    fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod

    - name: Setup Hugo # 步骤名自取
    uses: peaceiris/actions-hugo@v2 # hugo 官方提供的 action ,用于在任务环境中获取 hugo
    with:
    hugo-version: '0.59.0' # 获取指定版本的 hugo
    ```
    Reid
        9
    Reid  
    OP
       2022-06-06 17:00:24 +08:00
    @istevenshen https://github.com/Reid00/Reid00.github.io.source/runs/6752751574?check_suite_focus=true
    调整了,但是报错了,
    ```shell
    [submodule "themes/PaperMod"]
    path = themes/PaperMod
    url = https://github.com/adityatelange/hugo-PaperMod.git

    ```
    gitmodules 里面是这个,不太知道怎么改
    jaredyam
        10
    jaredyam  
       2022-06-07 09:53:23 +08:00
    只能说你跟随的这篇博文有些过时,现在 Github Action 渲染的 public 基本都放在 github.io 仓库的一个独立分支,hugo 官方指引里有教程。
    OOLAOO
        11
    OOLAOO  
       2022-06-07 10:29:47 +08:00
    同问题, 我用 github actions 部署 hexo 博客打不开, 自己部署就能打开
    Reid
        12
    Reid  
    OP
       2022-06-07 11:36:33 +08:00
    @jaredyam 21 年的确实不是最新的了,但是我看 actions-gh-pages
    还是提供了这种方式的, 说明还是兼容的吧,就是不清楚目前的错误在哪里
    Reid
        13
    Reid  
    OP
       2022-06-07 11:38:38 +08:00
    @OOLAOO 我知道我这边的问题了,因为 public 里面又**.reid00.io 的.git 文件,删除之后发现好了
    tabris17
        14
    tabris17  
       2022-06-12 11:45:47 +08:00
    我是原文的作者,这个 action 脚本我现在还在用,没什么问题呀。我的 hugo 版本是 0.55 ,难道是我用的 hugo 版本比较老的关系?
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     3353 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 27ms UTC 10:42 PVG 18:42 LAX 03:42 JFK 06:42
    Do have faith in what you're doing.
    ubao snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86