Deploy your Astro Site to GitLab Pages

You can use GitLab Pages to host an Astro site for your GitLab projects, groups, or user account.

  1. Set the correct .site in astro.config.mjs.

  2. Set dist in astro.config.mjs to public and public in astro.config.mjs to a newly named folder that is holding everything currently in public. The reasoning is because public is a second source folder in astro, so if you would like to output to public you’ll need to pull public assets from a different folder. Your astro.config.mjs might end up looking like this:

    export default defineConfig({
      sitemap: true,
      site: '',
  3. Create a file called .gitlab-ci.yml in the root of your project with the content below. This will build and deploy your site whenever you make changes to your content:

    image: node:14
          - node_modules/
        - npm install
        - npm run build
          - public
        - main

More Deployment Guides

Filter by deploy type