Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问是否能支持配置不同的RSS地址 #376

Closed
Mantyke opened this issue Oct 3, 2021 · 11 comments
Closed

请问是否能支持配置不同的RSS地址 #376

Mantyke opened this issue Oct 3, 2021 · 11 comments

Comments

@Mantyke
Copy link

Mantyke commented Oct 3, 2021

Hugo自动生成的RSS地址为index.xml
但如果在Page里指定地址为/index.xml,以Github Action进行自动部署,Github Action则会报错
image

我使用的Workflow为https://github.com/he-sb/tech/blob/master/.github/workflows/build.yml

如果有别的方法可以解决也请不吝赐教,非常感谢!

@QIN2DIM
Copy link
Contributor

QIN2DIM commented Oct 3, 2021

Hi~

可以提供更多关于工作流的日志细节吗,我在 链接指向的 GitHub Actions 中看到不到您说的 failed workflow。然后我简单复现了一下环境,拉取了同样的源码和工作流,并没有出现您说的问题0.0

另外,关于 Hugo RSS 的索引策略可以看一下官方文档的介绍

@QIN2DIM
Copy link
Contributor

QIN2DIM commented Oct 3, 2021

然后是关于您的工作流的写法我有很多疑惑,这个 build.yml 是用于远程仓库的吗,为什么要克隆“本地”代码

最近刚开始上手 workflow,大概看了一下您写的,如果您的情况是 Hugo 源码和 publishDir 渲染输出分别在一个仓库的不同分支下,GitHub Pages 指向 PublishDir 的 /root,完全可以直接 uses 官方提供的脚本呀0、0

@Mantyke
Copy link
Author

Mantyke commented Oct 3, 2021

然后是关于您的工作流的写法我有很多疑惑,这个 build.yml 是用于远程仓库的吗,为什么要克隆“本地”代码

最近刚开始上手 workflow,大概看了一下您写的,如果您的情况是 Hugo 源码和 publishDir 渲染输出分别在一个仓库的不同分支下,GitHub Pages 指向 PublishDir 的 /root,完全可以直接 uses 官方提供的脚本呀0、0

谢谢回答!我分开来说~
首先我在本地进行的步骤是:新建一个page页面,slug: "index.xml",这时运行本地预览,可以看到左侧导航栏出现RSS链接,点进去能正常跳转到index.xml
随后进行自动部署,在Bulid的部分报错。

我用的这个工作流来自于reuixiy/hugo-theme-meme#107
是从源代码仓库输出渲染到另一个仓库(目的是设置源代码仓库为私密),用这个工作流是因为我想在Blog页面上实现自动更新文章最后编辑时间,但如果使用checkout命令,则会导致所有页面的时间都同步更新为自动构建的时间。
实际使用时修改了其中一行,将 git clone --branch=master --quiet https://github.com/$SOURCE_REPO site修改为git clone --branch=main --quiet https://$SECRET@github.com/$SOURCE_REPO site。,用以clone私密仓库。

我看了Hugo文档的RSS查找逻辑,但是我仍然不太清楚如何让它生成别的RSS文件

@zhixuan2333
Copy link
Contributor

zhixuan2333 commented Oct 3, 2021

但如果在Page里指定地址为/index.xml,以Github Action进行自动部署,Github Action则会报错

应该是因为主题自动生成rss文件所以出错的。
虽然不是个很好的方法你可以在 config.yamlmenu.main改成这样

menu:
    main:
        - identifier: home
          name: Home
          url: /
          weight: -100
          pre: home
          params:
            ### For demonstration purpose, the home link will be open in a new tab
            newTab: false

        - identifier: rss
          name: rss
          url: /index.xml
          weight: -10
          pre: home
          params:
            ### For demonstration purpose, the home link will be open in a new tab
            newTab: true

实现自动更新文章最后编辑时间

虽然跟issue没有什么关系,就是有点在意这个。这是我的workflow,我是可以正常输出的。
顺便打个广告 https://zhixuan2333.github.io/posts/ce103e3b/

name: GitHub Page

on:
  push:
    branches:
      - master  # Set a branch to deploy

jobs:
  deploy:
    runs-on: ubuntu-18.04
    steps:
      - uses: actions/checkout@v2
        with:
          submodules: true  # Fetch Hugo themes (true OR recursive)
          fetch-depth: 0    # Fetch all history for .GitInfo and .Lastmod

      - name: Setup Hugo
        uses: peaceiris/actions-hugo@v2
        with:
          hugo-version: '0.87.0'
          extended: true

      - name: Cache resources
        uses: actions/cache@v2
        with:
          path: |
            resources
          key: ${{ runner.os }}-hugocache-${{ hashFiles('content/**/*') }}
          restore-keys: |
            ${{ runner.os }}-hugocache-

      - name: Build
        run: hugo --minify --gc

      - name: Deploy
        uses: peaceiris/actions-gh-pages@v3
        with:
          deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
          publish_dir: ./public
          external_repository: zhixuan2333/zhixuan2333.github.io
          user_name: 'github-actions[bot]'
          user_email: 'github-actions[bot]@users.noreply.github.com'
          full_commit_message: Deploy from ${{ github.repository }}@${{ github.sha }} 🚀

@Mantyke
Copy link
Author

Mantyke commented Oct 3, 2021

但如果在Page里指定地址为/index.xml,以Github Action进行自动部署,Github Action则会报错

应该是因为主题自动生成rss文件所以出错的。 虽然不是个很好的方法你可以在 config.yamlmenu.main改成这样

由衷感谢!已经在Blog里加上了。

↓ 问题关闭是点提交的时候按错了……以及我这边看你的workflow并不能解决自动更新文章最后编辑时间,可以检查一下,目前你Blog的所有文章页面都显示最后更新于 2021 年 10 月 3 日 20:04 +0900,这个时间应该是你最近一次部署的时间。
https://mantyke.icu/2021/47a5331b/
这是我之前对这个问题的研究(比较小白,出错见谅),可以参考。

@Mantyke Mantyke closed this as completed Oct 3, 2021
@Mantyke Mantyke reopened this Oct 3, 2021
@zhixuan2333
Copy link
Contributor

zhixuan2333 commented Oct 3, 2021

update.. 现在应该可以了

      - uses: actions/checkout@v2
        with:
          submodules: true  # Fetch Hugo themes (true OR recursive)
+         fetch-depth: 0    # Fetch all history for .GitInfo and .Lastmod

@Mantyke
Copy link
Author

Mantyke commented Oct 3, 2021

update.. 现在应该可以了

      - uses: actions/checkout@v2
        with:
          submodules: true  # Fetch Hugo themes (true OR recursive)
+         fetch-depth: 0    # Fetch all history for .GitInfo and .Lastmod

请教一下,具体是什么原因导致的?
orz我老是按错到close issue,希望不会给别人带来困扰

@Mantyke Mantyke closed this as completed Oct 3, 2021
@Mantyke Mantyke reopened this Oct 3, 2021
@zhixuan2333
Copy link
Contributor

actions/checkout@v2 默认不会克隆历史信息,加fetch-depth: 0就克隆完全的历史信息

@Mantyke
Copy link
Author

Mantyke commented Oct 3, 2021

actions/checkout@v2 默认不会克隆历史信息,加fetch-depth: 0就克隆完全的历史信息

明白了,谢谢!

@QIN2DIM
Copy link
Contributor

QIN2DIM commented Oct 3, 2021

我用的这个工作流来自于reuixiy/hugo-theme-meme#107 是从源代码仓库输出渲染到另一个仓库(目的是设置源代码仓库为私密)

巧了我最近也在研究这个方案https://blog.echosec.top/p/hugo-hugo-deploy/

@CaiJimmy
Copy link
Owner

如果是想把 index.xml 改成别的名字,例如 feed.xml,可以在 config.yaml 添加:

outputFormats:
    RSS:
        mediatype: "application/rss"
        baseName: "feed"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants