Unable to change source branch in GitHub Pages

前端 未结 3 593
离开以前
离开以前 2021-02-01 13:29

I have created a simple web site for GitHub Pages. The source of the site is in the \"master\" branch and the generated web site (what I want to see published) is under the \"gh

3条回答
  •  南方客
    南方客 (楼主)
    2021-02-01 13:44

    FWIW, this is the setup I used for publishing a personal page (i.e. https://user-name.github.io) using Next.js and gh-pages:

    1. Create a different default branch in your repo to work in (e.g. develop)
    2. Build a static export of your site: next build && next export
    3. Put a .nojekyll marker file in the export directory: touch out/.nojekyll
    4. Upload the static export to the master branch: gh-pages -t -b master -d out

    You can bundle these commands in package.json to get a convenient yarn deploy command:

    scripts: {
      ...
      "build": "next build",
      "export": "yarn run build && next export",
      "deploy": "yarn export && touch out/.nojekyll && gh-pages -t -b master -d out"
      ...
    

提交回复
热议问题