GitLab Pages | GitLab (2024)

  • Getting started
  • How it works
  • Access to your Pages site
  • Pages examples
  • Administer GitLab Pages for self-managed instances
    • Configure GitLab Pages in a Helm Chart (Kubernetes) instance
  • Security for GitLab Pages
    • Namespaces that contain .
  • Unique domains
  • Create multiple deployments
    • Example configuration
    • Enable multiple deployments
    • Limits
    • Path clash
    • Use multiple deployments to create pages environments
    • Deployments deletion
      • Auto-clean

Tier: Free, Premium, UltimateOffering: GitLab.com, Self-managed, GitLab Dedicated

With GitLab Pages, you can publish static websites directly from a repositoryin GitLab.

  • Use for any personal or business website.
  • Use any Static Site Generator (SSG) or plain HTML.
  • Create websites for your projects, groups, or user account.
  • Host your site on your own GitLab instance or on GitLab.com for free.
  • Connect your custom domains and TLS certificates.
  • Attribute any license to your content.

GitLab Pages | GitLab (1)

To publish a website with Pages, you can use any static site generator,like Gatsby, Jekyll, Hugo, Middleman, Harp, Hexo, or Brunch. You can alsopublish any website written directly in plain HTML, CSS, and JavaScript.

Pages does not support dynamic server-side processing, for instance, as .php and .asp requires.For more information, seeStatic vs dynamic websites.

Getting started

To create a GitLab Pages website:

DocumentDescription
Use the GitLab UI to create a simple .gitlab-ci.ymlAdd a Pages site to an existing project. Use the UI to set up a simple .gitlab-ci.yml.
Create a .gitlab-ci.yml file from scratchAdd a Pages site to an existing project. Learn how to create and configure your own CI file.
Use a .gitlab-ci.yml templateAdd a Pages site to an existing project. Use a pre-populated CI template file.
Fork a sample projectCreate a new project with Pages already configured by forking a sample project.
Use a project templateCreate a new project with Pages already configured by using a template.

To update a GitLab Pages website:

DocumentDescription
GitLab Pages domain names, URLs, and base URLsLearn about GitLab Pages default domains.
Explore GitLab PagesRequirements, technical aspects, specific GitLab CI/CD configuration options, Access Control, custom 404 pages, limitations, and FAQ.
Custom domains and SSL/TLS CertificatesCustom domains and subdomains, DNS records, and SSL/TLS certificates.
Let’s Encrypt integrationSecure your Pages sites with Let’s Encrypt certificates, which are automatically obtained and renewed by GitLab.
RedirectsSet up HTTP redirects to forward one page to another.

For more information, see:

DocumentDescription
Static vs dynamic websitesStatic versus dynamic site overview.
Modern static site generatorsSSG overview.
Build any SSG site with GitLab PagesUse SSGs for GitLab Pages.

How it works

To use GitLab Pages, you must create a project in GitLab to upload your website’sfiles to. These projects can be either public, internal, or private.

GitLab always deploys your website from a specific folder called public in yourrepository. When you create a new project in GitLab, a repositorybecomes available automatically.

To deploy your site, GitLab uses its built-in tool called GitLab CI/CDto build your site and publish it to the GitLab Pages server. The sequence ofscripts that GitLab CI/CD runs to accomplish this task is created from a file named.gitlab-ci.yml, which you can create and modify.A specific job called pages in the configuration file makes GitLab aware that you’re deploying aGitLab Pages website.

You can either use the GitLab default domain for GitLab Pages websites,*.gitlab.io, or your own domain (example.com). In that case, youmust be an administrator in your domain’s registrar (or control panel) to set it up with Pages.

The following diagrams show the workflows you might follow to get started with Pages.

GitLab Pages | GitLab (2)

Access to your Pages site

If you’re using GitLab Pages default domain (.gitlab.io), your website isautomatically secure and available under HTTPS. If you’re using your own customdomain, you can optionally secure it with SSL/TLS certificates.

If you’re using GitLab.com, your website is publicly available to the internet.To restrict access to your website, enable GitLab Pages Access Control.

If you’re using a self-managed instance, your websites are published on yourown server, according to the Pages settingschosen by your sysadmin, who can make them public or internal.

Pages examples

These GitLab Pages website examples can teach you advanced techniques to useand adapt for your own needs:

  • Posting to your GitLab Pages blog from iOS.
  • GitLab CI: Run jobs sequentially, in parallel, or build a custom pipeline.
  • .
  • Building a new GitLab docs site with Nanoc, GitLab CI, and GitLab Pages.
  • Publish code coverage reports with GitLab Pages.

Administer GitLab Pages for self-managed instances

If you are running a self-managed instance of GitLab,follow the administration steps to configure Pages.

Watch a video tutorial about how to get started with GitLab Pages administration.

Configure GitLab Pages in a Helm Chart (Kubernetes) instance

To configure GitLab Pages on instances deployed via Helm chart (Kubernetes), use either:

  • The gitlab-pages subchart.
  • An external GitLab Pages instance.

Security for GitLab Pages

Namespaces that contain .

If your username is example, your GitLab Pages website is located at example.gitlab.io.GitLab allows usernames to contain a ., so a user named bar.example could createa GitLab Pages website bar.example.gitlab.io that effectively is a subdomain of yourexample.gitlab.io website. Be careful if you use JavaScript to set cookies for your website.The safe way to manually set cookies with JavaScript is to not specify the domain at all:

// Safe: This cookie is only visible to example.gitlab.iodocument.cookie = "key=value";// Unsafe: This cookie is visible to example.gitlab.io and its subdomains,// regardless of the presence of the leading dot.document.cookie = "key=value;domain=.example.gitlab.io";document.cookie = "key=value;domain=example.gitlab.io";

This issue doesn’t affect users with a custom domain, or users who don’t set anycookies manually with JavaScript.

By default, every project in a group shares the same domain, for example, group.gitlab.io. This means that cookies are also shared for all projects in a group.

To ensure each project uses different cookies, enable the Pages unique domains feature for your project.

Unique domains

History

  • Introduced in GitLab 15.9 with a flag named pages_unique_domain. Disabled by default.
  • Enabled by default in GitLab 15.11.
  • Feature flag removed in GitLab 16.3.

By default, every new project uses pages unique domain. This is to avoid projects on the same groupto share cookies.

The project maintainer can disable this feature on:

  1. On the left sidebar, select Search or go to and find your project.
  2. Select Deploy > Pages.
  3. Deselect the Use unique domain checkbox.
  4. Select Save changes.

Create multiple deployments

Tier: Premium, UltimateOffering: GitLab.com, Self-managed, GitLab DedicatedStatus: Experiment

History

  • Introduced in GitLab 16.7 as an experiment with a flag named pages_multiple_versions_setting, disabled by default.

On self-managed GitLab, by default this feature is not available. To make it available,an administrator can enable the feature flag namedpages_multiple_versions_setting. On GitLab.com and GitLab Dedicated, this feature is not available. This feature is not ready for production use.

Use the pages.path_prefix CI/CD option to configure a prefix for the GitLab Pages URL.A prefix allows you to differentiate between multiple GitLab Pages deployments:

  • Main Pages deployment: a Pages deployment created with a blank path_prefix.
  • Extra Pages deployment: a Pages deployment created with a non-blank path_prefix

The value of pages.path_prefix is:

  • Converted to lowercase.
  • Shortened to 63 bytes.
  • Any character except numbers (0-9) and letter (a-z) is replaced with a hyphen (-).
  • Leading and trailing hyphens (-) are removed.

Example configuration

Consider a project such as https://gitlab.example.com/namespace/project. By default, its main Pages deployment can be accessed through:

  • When using a unique domain: https://project-namespace-uniqueid.gitlab.io/.
  • When not using a unique domain: https://namespace.gitlab.io/project.

If a pages.path_prefix is configured to the project branch names,like path_prefix = $CI_COMMIT_BRANCH, and there’s abranch named username/testing_feature, this extra Pages deployment would be accessible through:

  • When using a unique domain: https://project-namespace-uniqueid.gitlab.io/username-testing-feature.
  • When not using a unique domain: https://namespace.gitlab.io/project/username-testing-feature.

Enable multiple deployments

To enable multiple GitLab Pages deployments:

  1. On the left sidebar, select Search or go to and find your project.
  2. Select Deploy > Pages.
  3. Select Use multiple deployments.

Limits

The number of extra deployments is limited by the root-level namespace. For specific limits for:

  • GitLab.com, see Other limits.
  • Self-managed GitLab instances, seeNumber of extra Pages deployments when using multiple deployments.

Path clash

pages.path_prefix can take dynamic values from CI/CD variablesthat can create pages deployments which could clash with existing paths in your site.For example, given an existing GitLab Pages site with the following paths:

/index.html/documents/index.html

If a pages.path_prefix is documents, that version will override the existing path.In other words, https://namespace.gitlab.io/project/documents/index.html will point to the/index.html on the documents deployment of the site, instead of documents/index.html of themain deployment of the site.

Mixing CI/CD variables with other strings can reduce the path clashpossibility. For example:

pages: stage: deploy script: - echo "Pages accessible through ${CI_PAGES_URL}/${PAGES_PREFIX}" variables: PAGES_PREFIX: "" # No prefix by default (master) pages: path_prefix: "$PAGES_PREFIX" artifacts: paths: - public rules: - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # Run on default branch (with default PAGES_PREFIX) - if: $CI_COMMIT_BRANCH == "staging" # Run on master (with default PAGES_PREFIX) variables: PAGES_PREFIX: '_stg' # Prefix with _stg for the staging branch - if: $CI_PIPELINE_SOURCE == "merge_request_event" # Conditionally change the prefix for Merge Requests when: manual # Run pages manually on Merge Requests variables: PAGES_PREFIX: 'mr-$CI_MERGE_REQUEST_IID' # Prefix with the mr-<iid>, like `mr-123`

Some other examples of mixing variables with strings for dynamic prefixes:

  • pages.path_prefix: 'mr-$CI_COMMIT_REF_SLUG': Branch or tag name prefixed with mr-, like mr-branch-name.
  • pages.path_prefix: '_${CI_MERGE_REQUEST_IID}_': Merge request numberprefixed ans suffixed with _, like _123_.

Use multiple deployments to create pages environments

You can use multiple GitLab Pages deployments to create a new environment.For example:

pages: stage: deploy script: - echo "Pages accessible through ${CI_PAGES_URL}/${PAGES_PREFIX}" variables: PAGES_PREFIX: "" # no prefix by default (master) pages: path_prefix: "$PAGES_PREFIX" environment: name: "Pages ${PAGES_PREFIX}" url: "${CI_PAGES_URL}/${PAGES_PREFIX}" artifacts: paths: - public rules: - if: $CI_COMMIT_BRANCH == "staging" # ensure to run on master (with default PAGES_PREFIX) variables: PAGES_PREFIX: '_stg' # prefix with _stg for the staging branch - if: $CI_PIPELINE_SOURCE == "merge_request_event" # conditionally change the prefix on Merge Requests when: manual # run pages manually on Merge Requests variables: PAGES_PREFIX: 'mr-$CI_MERGE_REQUEST_IID' # prefix with the mr-<iid>, like `mr-123`

With this configuration, users will have the access to each GitLab Pages deployment through the UI.When using environments for pages, all pages environments arelisted on the project environment list.

You can also group similar environments together.

Deployments deletion

Auto-clean

Extra Pages deployments, created by a merge request with a path_prefix, are automatically deleted when themerge request is closed or merged.

GitLab Pages | GitLab (2024)

FAQs

What are the limitations of GitLab pages? ›

Release notes. Currently, GitLab Pages have limitations for site size (1 GB) and the number of files (200,000). These limitations are not customizable in GitLab.com (SaaS), but self-managed has this capability.

How many GitLab pages can I have? ›

In any case, we don't set a limit the number of pages a user can make on GitLab.com.

Is GitLab Pages free? ›

Host your site on your own GitLab instance or on GitLab.com for free. Connect your custom domains and TLS certificates. Attribute any license to your content.

What is the limit of Git pages? ›

Usage limits

Published GitHub Pages sites may be no larger than 1 GB. GitHub Pages deployments will timeout if they take longer than 10 minutes. GitHub Pages sites have a soft bandwidth limit of 100 GB per month. GitHub Pages sites have a soft limit of 10 builds per hour.

How many pages can you have in GitLab API? ›

Description. Currently the per_page parameter for API pagination defaults to 20 and can be set to a maximum of 100 .

Does GitLab have an equivalent to GitHub Pages? ›

Repository Hosting: GitHub Pages allows you to host static websites directly from a GitHub repository. It automatically deploys the website whenever changes are pushed to the repository. GitLab Pages, on the other hand, also allows hosting static websites but is limited to GitLab repositories only.

Where are GitLab pages stored? ›

Follow the steps below to change the default path where GitLab Pages' contents are stored.
  • Pages are stored by default in /home/git/gitlab/shared/pages . If you wish to store them in another location you must set it up in gitlab.yml under the pages section: ...
  • Restart GitLab.

Is GitLab not free anymore? ›

SaaS. After the grace period has expired, GitLab will revert the namespace to the "Free" tier. No data will be lost, but paid features will not be functional anymore.

Is GitLab owned by Microsoft? ›

Although commonly confused — largely because of their names — they are owned and operated by different companies: GitHub by Microsoft and GitLab by its eponymous organization. They are each spaces for developers to work on Git projects, collaborate, and share and test their work.

Is it better to use GitHub or GitLab? ›

GitHub places more of a focus on third-party integrations with its vast marketplace of custom apps and actions.. GitLab tries to offer most of the functionality in their product without needing to use third-party integrations. Vastly cheaper with paid plans starting from $4 per user/month.

Does GitLab have a storage limit? ›

All projects on GitLab SaaS have 10 GiB of free storage for their Git repository and Large File Storage (LFS). When a project's repository and LFS exceed 10 GiB, the project is set to a read-only state.

What is the pull limit in GitLab? ›

Each command has a rate limit of 600 per minute. For example: git push has a rate limit of 600 per minute. git pull has its own rate limit of 600 per minute.

How do I increase the size limit in GitLab? ›

You can change the maximum file size for attachments in comments and replies in GitLab: On the top bar, select Menu > Admin. In the left sidebar, select Settings > General, then expand Account and limit. Increase or decrease by changing the value in Maximum attachment size (MB).

What are the user limitations in GitLab? ›

You can manage the users in each of your personal projects, but you cannot have more than five users in all of your personal projects. You should move your personal project to a group so that you can: Increase the amount of users to more than five.

What are the limitations of Git? ›

Native Git is inefficient when asked to store large binary files (videos) or large numbers of binary files (images, PDFs) because every revision of every file is stored locally. No granular support for user roles. Users usually either have full read-write access to a repository or read-only access.

Does GitLab have a file size limit? ›

A 100 MiB per-file limit applies when pushing new files to any project in the Free tier.

Top Articles
Latest Posts
Article information

Author: Twana Towne Ret

Last Updated:

Views: 5847

Rating: 4.3 / 5 (64 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Twana Towne Ret

Birthday: 1994-03-19

Address: Apt. 990 97439 Corwin Motorway, Port Eliseoburgh, NM 99144-2618

Phone: +5958753152963

Job: National Specialist

Hobby: Kayaking, Photography, Skydiving, Embroidery, Leather crafting, Orienteering, Cooking

Introduction: My name is Twana Towne Ret, I am a famous, talented, joyous, perfect, powerful, inquisitive, lovely person who loves writing and wants to share my knowledge and understanding with you.