#Deploy in GitHub pages
2 messages · Page 1 of 1 (latest)
To deploy your Astro site to GitHub Pages, you need to set the site and base options in your astro.config.mjs file.
The site option should be set to your GitHub Pages URL. This will typically be in the format <https://<username>.github.io.>
The base option should be set to your repository name, prefixed with a forward slash. This is so that Astro understands your website’s root is /my-repo, rather than the default /.
Here's an example:
import { defineConfig } from 'astro/config'
export default defineConfig({
site: '<https://<username>.github.io',>
base: '/<my-repo>',
})
Replace <username> with your GitHub username and <my-repo> with your repository name.
Please note that you should not set a base parameter if your page is served from the root folder or if your repository is located at <https://github.com/<USERNAME>/<USERNAME>.github.io.>
Also, when the base value is configured, all of your internal page links must be prefixed with your base value. For example:
<a href="/my-repo/about">About</a>