It is super easy to publish SvelteKit project on GitHub Pages. Create a GitHub repo before starting this.
npm create svelte@latest my-app
npm i -D @sveltejs/adapter-static gh-pages
import adapter from '@sveltejs/adapter-static';
Add the following to src/routes/+layout.js
export const prerender = true;
"gh-pages": "npm run build && npx gh-pages -d build"
Now you just need to run npm run gh-pages
.
If you are using a postcss such as Tailwind css, you need to add an empty .nojekyll
file to the gh-pages
branch.