Coder Social home page Coder Social logo

layzeedk / github-pages-docusaurus Goto Github PK

View Code? Open in Web Editor NEW
65.0 1.0 32.0 222 KB

A Docusaurus website deployed to GitHub Pages using GitHub Actions.

Home Page: https://layzeedk.github.io/github-pages-docusaurus/

License: MIT License

JavaScript 48.00% TypeScript 31.61% CSS 15.88% MDX 4.51%
docusaurus github-actions github-deployment github-environments github-pages

github-pages-docusaurus's Introduction

Deploy Docusaurus website to GitHub Pages using GitHub Actions

This repository is an example of deploying a Docusaurus website to GitHub Pages using GitHub Actions.

Configuring the GitHub repository

It uses the new GitHub Pages experience with GitHub Actions to deploy the website.

Enable this experience in GitHub.com -> Repository -> Settings -> Pages -> Build and deployment -> Source by selecting GitHub Actions instead of the legacy Deploy from a branch option.

In GitHub.com -> Repository -> Settings -> Environments you should see a GitHub Environment named github-pages.

Configuring Docusaurus

Generate a Docusuarus website using the following command:

yarn create docusaurus <folder-name> classic --typescript

Make the following changes to the docusaurus.config.js configuration file:

  1. Create the constants organizationName and projectName

    const organizationName = "<github-organization-name>";
    const projectName = "<repository-name>";
  2. Set the URL

    const config = {
      // (...)
      url: `https://${organizationName}.github.io`,
    };
    const baseUrl = /${projectName}/`;
  3. Configure the base URL

    const config = {
      // (...)
      baseUrl: `/${projectName}/`,
    };
  4. Set the organizationName and projectName options

    const organizationName = "<github-organization-name>";
    const projectName = "<repository-name>";
    
    const config = {
      // (...)
      organizationName,
      projectName,
    };
  5. Configure the blog and docs edit URLs

    const config = {
      // (...)
      presets: [
        [
          "classic",
          /** @type {import('@docusaurus/preset-classic').Options} */
          ({
            // (...)
            docs: {
              // (...)
              editUrl: `https://github.com/${organizationName}/${projectName}/tree/main/`,
            },
            blog: {
              // (...)
              editUrl: `https://github.com/${organizationName}/${projectName}/tree/main/`,
            },
          }),
        ],
      ],
    };

Adding a GitHub Actions deployment workflow

Use a GitHub Actions workflow template for GitHub Pages from the actions/starter-workflows repository. Place it in .github/workflows/<workflow-name>.yml.

Add steps for building the website before the GitHub Pages actions are executed and specify the path to the actions/upload-pages-artifact:

# (...)
jobs:
  deploy:
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      # ๐Ÿ‘‡ Build steps
      - name: Set up Node.js
        uses: actions/setup-node@v3
        with:
          node-version: 16.x
          cache: yarn
      - name: Install dependencies
        run: yarn install --frozen-lockfile --non-interactive
      - name: Build
        run: yarn build
      # ๐Ÿ‘† Build steps
      - name: Setup Pages
        uses: actions/configure-pages@v3
      - name: Upload artifact
        uses: actions/upload-pages-artifact@v2
        with:
          # ๐Ÿ‘‡ Specify build output path
          path: build
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v2

github-pages-docusaurus's People

Contributors

layzeedk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

github-pages-docusaurus's Issues

TYSM

Thanks a lot for this. I was banging my head against the wall trying to get Pages working with the legacy workflow and weird stuff was happening like it showing the readme file etc.

The workflow and instructions combined worked instantly. You made my day.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.