├── public
├── .nojekyll
├── favicon.ico
├── v2osk-1Z2niiBPg5A-unsplash.jpg
└── qingbao-meng-01_igFr7hd4-unsplash.jpg
├── tsconfig.json
├── .gitignore
├── nuxt.config.ts
├── pages
├── about.vue
└── index.vue
├── package.json
└── README.md
/public/.nojekyll:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./.nuxt/tsconfig.json"
3 | }
4 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | *.log*
3 | .nuxt
4 | .nitro
5 | .cache
6 | .output
7 | .env
8 | dist
9 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lucpotage/nuxt-github-pages/HEAD/public/favicon.ico
--------------------------------------------------------------------------------
/public/v2osk-1Z2niiBPg5A-unsplash.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lucpotage/nuxt-github-pages/HEAD/public/v2osk-1Z2niiBPg5A-unsplash.jpg
--------------------------------------------------------------------------------
/nuxt.config.ts:
--------------------------------------------------------------------------------
1 | export default defineNuxtConfig({
2 | app: {
3 | baseURL: '/nuxt-github-pages/',
4 | buildAssetsDir: 'assets'
5 | }
6 | })
--------------------------------------------------------------------------------
/public/qingbao-meng-01_igFr7hd4-unsplash.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lucpotage/nuxt-github-pages/HEAD/public/qingbao-meng-01_igFr7hd4-unsplash.jpg
--------------------------------------------------------------------------------
/pages/about.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
About
5 | Home
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/pages/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
Home
5 | About
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "private": true,
3 | "scripts": {
4 | "build": "nuxt build",
5 | "dev": "nuxi dev",
6 | "generate": "nuxi generate",
7 | "preview": "nuxi preview",
8 | "postinstall": "nuxi prepare",
9 | "deploy": "gh-pages --dotfiles -d .output/public"
10 | },
11 | "devDependencies": {
12 | "gh-pages": "^4.0.0",
13 | "nuxt": "^3.1.2"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Here is how to deploy a Nuxt 3 project on GitHub Pages:
2 |
3 | # How to
4 |
5 | 1. Install dev dependency `gh-pages`
6 | 2. Add the script `"deploy": "gh-pages -d dist"` in package.json file
7 | 3. Specifiy app `baseURL` in nuxt.config.ts
8 | 4. Specifiy `buildAssetsDir` in nuxt.config.ts that doesn't start with an underscore `_`. See the router config example below
9 | 5. Create an empty file `.nojekyll` at the root of the project
10 | 6. Generate with `npm run generate`
11 | 7. Deploy with `npm run deploy`
12 |
13 | Router config:
14 |
15 | ```ts
16 | export default defineNuxtConfig({
17 | app: {
18 | baseURL: '/nuxt-github-pages/', // baseURL: '//'
19 | buildAssetsDir: 'assets', // don't use "_" at the begining of the folder name to avoids nojkill conflict
20 | }
21 | }
22 | ```
23 |
24 | # What it does
25 |
26 | The dependency will copy your dist content to a specific `gh-pages` branch that will be served by GitHub Pages. If you go to your Settings/Pages, you’ll see the active branch for your site.
27 |
28 | The site is accessible on `https://.github.io//`. For this repository, the site is https://lucpotage.github.io/nuxt-github-pages/.
29 |
30 | You can rely on GitHub Actions too. More info here: https://medium.com/front-end-weekly/ci-cd-with-github-actions-to-deploy-on-github-pages-73e225f8f131
31 |
32 | More information about buildAssetsDir config: https://github.blog/2009-12-29-bypassing-jekyll-on-github-pages/
--------------------------------------------------------------------------------