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
site
inastro.config.mjs
. -
Set
outDir:public
inastro.config.mjs
. This setting instructs Astro to put the static build output in a folder calledpublic
, which is the folder required by GitLab Pages for exposed files.If you were using the
public/
directory as a source of static files in your Astro project, rename it and use that new folder name inastro.config.mjs
for the value ofpublicDir
.For example, here are the correct
astro.config.mjs
settings when thepublic/
directory is renamed tostatic/
: -
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: