Setting up a GitHub Docusaurus repo and deploying it using GitHub Action and Pages #12042
Replies: 3 comments
-
|
The error is from Jekyll, not Docusaurus. GitHub Pages defaults to Jekyll-based builds unless you explicitly disable it. Your workflow is triggering GitHub Pages' legacy Jekyll pipeline, which is trying to process your Docusaurus output directory as a Jekyll site. The fix: add a In your Docusaurus config, add // docusaurus.config.ts
export default {
// ...
trailingSlash: false,
};In your GitHub Actions workflow, add a step after the build: - name: Build
run: npm run build
- name: Add .nojekyll
run: touch build/.nojekyll
- name: Deploy to GitHub Pages
uses: actions/upload-pages-artifact@v3
with:
path: build/The correct GitHub Actions workflow for Docusaurus + GitHub Pages: name: Deploy Docusaurus to Pages
on:
push:
branches: [main]
permissions:
contents: read
pages: write
id-token: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- run: npm run build
- run: touch build/.nojekyll
- uses: actions/upload-pages-artifact@v3
with:
path: build/
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/deploy-pages@v4
id: deploymentIn GitHub repo Settings → Pages → set Source to "GitHub Actions" (not "Deploy from branch"). That's the setting that switches from Jekyll to the artifact-based pipeline. For versioning: Docusaurus's built-in versioning ( |
Beta Was this translation helpful? Give feedback.
-
The things appearing in the navbar are navbar items you can add to your site configuration. It's documented in our official docs and our built-in tutorial embedded in newly initialized sites: https://tutorial.docusaurus.io/docs/tutorial-extras/manage-docs-versions
Docusaurus may not work like other docs systems you are used to. Docusaurus assumes you are putting all your doc versions on the If this is not what you look for and want to keep versioned docs on versioned branches, you need to build one independant Docusaurus site per versioned branch, instead of one consolidated site. GitHub pages is not a good host for that because it doesn't support multiple deployments at once afaik. |
Beta Was this translation helpful? Give feedback.
-
|
Hi Aaron, I forked your repository, fixed the configuration and build dependencies, and submitted a Pull Request: AaronNGray#1. Here is what was fixed:
Once you merge the PR, go to Settings -> Pages in your repository and set the Source under Build and deployment to "GitHub Actions". |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I am looking for an example of how to deploy a Docusaurus documentation website with the same VERSION and LANGUAGE dropdowns, are these plugins ? I need to have my versioning parallel to my GitHub version tags.
I have looked at https://docusaurus.io/docs/deployment#deploying-to-github-pages
Also to deploy it so it looks simular in format and location to Docusaurus own Docs on a GitHub Pages sub page.
I cloned Docusaurus, modifying the default export at docusaurus.config.ts as https://github.com/AaronNGray/docusaurus-docs-test
I set up GitHub Actions and am now getting the following error :-
Rendering Markup: assets/css/style.scss github-pages 232 | Error: No such file or directory @ dir_chdir0 - /github/workspace/docs
Hoping this is a simple error.
Many thanks in advance !
Beta Was this translation helpful? Give feedback.
All reactions