Deployment

GitLab Pages

Deploy your Lithos site to GitLab Pages with integrated CI/CD pipelines.
Properties5
Aliases #GitLab Pages Deployment
Is BaseNo
Iconi-lucide-gitlab
Order3
Tags #deployment #gitlab #ci-cd

GitLab Pages provides static hosting integrated with GitLab's CI/CD pipelines. Perfect for teams already using GitLab for version control.

Repository Setup

  1. Create a GitLab repository for your Lithos project
  2. Push your project (excluding node_modules and .output)
  3. GitLab Pages is automatically enabled when you add a .gitlab-ci.yml

GitLab CI Configuration

Create .gitlab-ci.yml in your repository root:

image: node:20

stages:
  - build
  - deploy

cache:
  key: ${CI_COMMIT_REF_SLUG}
  paths:
    - node_modules/
    - .nuxt/

variables:
  NUXT_APP_BASE_URL: /${CI_PROJECT_NAME}/

build:
  stage: build
  script:
    - npm ci
    - npm run generate
  artifacts:
    paths:
      - .output/public

pages:
  stage: deploy
  script:
    - mv .output/public public
  artifacts:
    paths:
      - public
  only:
    - main
Project vs User Pages
  • Project Pages: username.gitlab.io/project-name (set NUXT_APP_BASE_URL)
  • User Pages: username.gitlab.io (no base URL needed)

Configuration Options

Custom Domain

  1. Go to Settings > Pages
  2. Add your custom domain
  3. Configure DNS:
    • A record: 35.185.44.232
    • CNAME: namespace.gitlab.io
  4. Enable Force HTTPS

Environment Variables

Set variables in Settings > CI/CD > Variables:

variables:
  NUXT_PUBLIC_SITE_URL: ${CI_PAGES_URL}
  
build:
  script:
    - npm run generate

Branch-specific Deployments

Deploy different branches to different URLs:

pages:
  stage: deploy
  script:
    - mv .output/public public
  artifacts:
    paths:
      - public
  rules:
    - if: $CI_COMMIT_BRANCH == "main"

pages:preview:
  stage: deploy
  script:
    - mv .output/public public
  artifacts:
    paths:
      - public
  environment:
    name: review/$CI_COMMIT_REF_SLUG
    url: https://$CI_PROJECT_NAMESPACE.gitlab.io/-/$CI_PROJECT_NAME/-/jobs/$CI_JOB_ID/artifacts/public/index.html
  rules:
    - if: $CI_MERGE_REQUEST_IID

Private Projects

For private repositories, enable Pages access:

  1. Go to Settings > General > Visibility
  2. Expand Pages
  3. Choose access level:
    • Everyone - Public access
    • Only project members - Requires authentication

Troubleshooting

Pipeline Failures

Check the pipeline logs in CI/CD > Pipelines. Common issues:

  • Missing node_modules cache (first run takes longer)
  • Node version too old (ensure image: node:20)
  • Incorrect artifact paths

404 on Subpages

Ensure the base URL is correctly set. For project pages:

variables:
  NUXT_APP_BASE_URL: /${CI_PROJECT_NAME}/

Slow Builds

Enable caching to speed up builds:

cache:
  key: ${CI_COMMIT_REF_SLUG}
  paths:
    - node_modules/
    - .nuxt/

GitLab vs GitHub Pages

FeatureGitLab PagesGitHub Pages
CI/CDBuilt-inGitHub Actions
Private reposSupportedLimited on free tier
Custom domainsYes, with SSLYes, with SSL
Size limits100MB artifacts1GB total
Access controlFine-grainedPublic only (free)