How to Deploy to GitHub Pages

Deploying to GitHub Pages

This blog is ready to be deployed to GitHub Pages. Here is how you can do it.

Steps

  1. Create a new repository on GitHub.
  2. Push this code to the repository.
  3. Go to Settings > Pages.
  4. Source: GitHub Actions.
  5. GitHub will detect the Astro project and suggest a workflow.

Configuration

If you are deploying to a user site (username.github.io), set site in astro.config.mjs:

export default defineConfig({
  site: 'https://username.github.io',
  // ...
});

If deploying to a project site (username.github.io/repo), set base as well:

export default defineConfig({
  site: 'https://username.github.io',
  base: '/repo',
});