GitHub发布Quarto网站时工作流报错:指定路径非项目目录
解决Quarto部署报错:指定路径不是网站/书籍项目
问题根源就是你推测的——Quarto项目存放在仓库子目录,但工作流默认在根目录执行,找不到项目核心配置文件(比如_quarto.yml),因此触发报错。
修复步骤
1. 确认项目子目录路径
先明确你的Quarto项目所在的子目录名称,比如docs、my-quarto-site这类。
2. 修改工作流配置
需要针对两个关键步骤调整:
(1)安装依赖(若requirements.txt在子目录)
如果你的依赖清单文件也在Quarto项目的子目录里,要给pip install步骤指定工作目录:
- run: pip install -r requirements.txt working-directory: ./你的子目录名称
(2)指定Quarto项目路径发布
在Render and Publish步骤中添加path参数,直接指向你的项目子目录:
- name: Render and Publish uses: quarto-dev/quarto-actions/publish@v2 with: target: gh-pages path: ./你的子目录名称 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
完整修改后的工作流示例
假设项目子目录为site,完整配置如下:
on: workflow_dispatch: push: branches: main name: Quarto Publish jobs: build-deploy: runs-on: ubuntu-latest permissions: contents: write steps: - name: Check out repository uses: actions/checkout@v3 with: fetch-depth: 0 - name: Set up Quarto uses: quarto-dev/quarto-actions/setup@v2 - name: Install Python and Dependencies uses: actions/setup-python@v4 with: python-version: '3.10' cache: 'pip' - run: pip install jupyter - run: pip install -r requirements.txt working-directory: ./site - name: Render and Publish uses: quarto-dev/quarto-actions/publish@v2 with: target: gh-pages path: ./site env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
验证要点
- 确认子目录下存在
_quarto.yml文件,这是Quarto识别项目的核心标识 - 替换路径时要和仓库内实际子目录名称完全匹配
内容的提问来源于stack exchange,提问作者Anne Bernard
相关产品推荐
相关产品推荐

