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.
How to deploy
Section titled How to deploy-
Set the correct
.siteinastro.config.mjs. -
Set
distinastro.config.mjstopublicandpublicinastro.config.mjsto a newly named folder that is holding everything currently inpublic. The reasoning is becausepublicis a second source folder in astro, so if you would like to output topublicyou’ll need to pull public assets from a different folder. Yourastro.config.mjsmight end up looking like this:export default defineConfig({ sitemap: true, site: 'https://astro.build/', }); -
Create a file called
.gitlab-ci.ymlin 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 pages: cache: paths: - node_modules/ script: - npm install - npm run build artifacts: paths: - public only: - main