Sveltekit Gh Pages screenshot

Sveltekit Gh Pages

Author Avatar Theme by Metonym
Updated: 22 May 2025
95 Stars

Minimal SvelteKit set-up made deployable to GitHub Pages.

Categories

Overview:

SvelteKit-gh-pages is a minimal static SvelteKit setup that is designed to be deployable to GitHub Pages. It provides a streamlined process for deploying SvelteKit apps on GitHub Pages without the need for complex configuration.

Features:

  • Static adapter integration: The SvelteKit static adapter is used to prerender the app, allowing for improved performance and faster loading times.
  • Configuration modification: The paths.base configuration in the SvelteKit config file needs to be modified to match the GitHub Pages subpath for the repository.
  • Bypassing Jekyll: A .nojekyll file needs to be added to the static folder to bypass Jekyll on GitHub Pages and ensure that static assets are copied correctly.

Installation:

To install the SvelteKit-gh-pages theme, follow these steps:

  1. Install the static adapter for SvelteKit by running the following command:
npm install --save-dev @sveltejs/adapter-static
  1. Update the svelte.config.js file at the top-level of your project to include the following code:
export default {
  kit: {
    adapter: adapter(), // Import and initialize the static adapter
    prerender: true, // Enable prerendering for improved performance
  },
};
  1. Modify the paths.base configuration in the svelte.config.js file to match the subpath of your GitHub Pages repository. For example, if your repository is named sveltekit-gh-pages, the paths.base should be set to /sveltekit-gh-pages.

  2. Add an empty .nojekyll file to the static folder in your project. This will bypass Jekyll on GitHub Pages.

  3. Update the deploy script in your package.json file to include the following configuration:

{
  "scripts": {
    "deploy": "gh-pages -d build -t true"
  }
}

Summary:

SvelteKit-gh-pages is a convenient solution for deploying SvelteKit apps on GitHub Pages. By integrating the static adapter, modifying the configuration, and bypassing Jekyll, developers can easily deploy their apps on GitHub Pages without any hassle.