I've had success using the browsable artifacts for this purpose. In your example, you would create a job for your develop branch and set the PUBLIC_URL to the path on gitlab.io where the job's artifacts are published:

develop:
    artifacts:
        paths:
          - public

    environment:
        name: Develop
        url: "https://$CI_PROJECT_NAMESPACE.gitlab.io/-/$CI_PROJECT_NAME/-/jobs/$CI_JOB_ID/artifacts/public/index.html"

    script: |
        # whatever

    stage: deploy

    variables:
        PUBLIC_URL: "/-/$CI_PROJECT_NAME/-/jobs/$CI_JOB_ID/artifacts/public"

Setting the environment as indicated produces a »Review app« link in relevant merge requests, allowing you to get to the artifacts with a single click.

Note: if your repository is in a subgroup, you need to insert the subgroup name in two places above above between /-/ and $CI_PROJECT_NAME for the resulting URLs to work.

Answer from joki on Stack Overflow
🌐
GitLab
gitlab.com › gitlab.org › gitlab foss › #40686
Metion in documentation that gitlab pages works only with "public" directory (#40686) · Issues · GitLab.org / GitLab FOSS · GitLab
Today I run into somehow confusing "pages:gitlab pages failed to extract" problem on a try to publish my custom static pages with gitlab.io. It turned out that I'm...
Discussions

git - Deploying GitLab pages for different branches - Stack Overflow
So the path to pages sources would be like public/$CI_PIPELINE_ID/. Then the whole public folder should be defined as artifacts with specific unique name (here again "$CI_PIPELINE_ID" can be used). Unique name for artifacts is needed to not override the artifacts with the next pipeline execution (if name is not specified, the default name will be taken https://docs.gitlab... More on stackoverflow.com
🌐 stackoverflow.com
continuous integration - GitLab CI/CD removes old artifacts from pages public folder - Stack Overflow
I'm trying to deploy multiple versions of a static website to public of GitLab pages from GitLab CI/CD. My strategy is to have the tag or branch name in the path such as pages.foo.com/project/main... More on stackoverflow.com
🌐 stackoverflow.com
Gitlab Pages: /public cannot be used for the publicly present files.
Specifically, the issue is with the part where -d public is specified to replace /dist, as Gitlab requires that the deployment folder is named public, as such, the statusfy client errors out because it cannot create the distribution files in the directory it already uses to pull the ... More on github.com
🌐 github.com
2
June 13, 2022
Downloadable file on Gitlab Pages
Anything that ends up in the public folder of the pages job will get copied to gitlab pages The public/ directory is the root of the pages sites, so wherever you put the file in that directory is where you can download it from. Using an ubuntu iso as an example: pages: image: ubuntu:22.04 script: - apt-get update; apt-get -y install curl - mkdir public - curl http://ubuntu.osuosl.org/releases/22.04/ubuntu-22.04.2-live-server-amd64.iso -o public/ubuntu.iso artifacts: paths: - public Then you can download that file from https://username.gitlab.io/yourrepo/ubuntu.iso More on reddit.com
🌐 r/gitlab
3
4
June 12, 2023
🌐
GitLab
forum.gitlab.com › how to use gitlab
Gitlab Pages html in project's build folder - How to Use GitLab - GitLab Forum
May 5, 2021 - I just finished a complex static ... Gitlab Pages easily deployed to the expected namespace URL when I followed the Gitlab’s docs for plain pages but in those cases the public folder was always in the root directory of the project. //.gitlab-ci.yml pages: stage: deploy ...
Top answer
1 of 6
48

I've had success using the browsable artifacts for this purpose. In your example, you would create a job for your develop branch and set the PUBLIC_URL to the path on gitlab.io where the job's artifacts are published:

develop:
    artifacts:
        paths:
          - public

    environment:
        name: Develop
        url: "https://$CI_PROJECT_NAMESPACE.gitlab.io/-/$CI_PROJECT_NAME/-/jobs/$CI_JOB_ID/artifacts/public/index.html"

    script: |
        # whatever

    stage: deploy

    variables:
        PUBLIC_URL: "/-/$CI_PROJECT_NAME/-/jobs/$CI_JOB_ID/artifacts/public"

Setting the environment as indicated produces a »Review app« link in relevant merge requests, allowing you to get to the artifacts with a single click.

Note: if your repository is in a subgroup, you need to insert the subgroup name in two places above above between /-/ and $CI_PROJECT_NAME for the resulting URLs to work.

2 of 6
35

It is possible to keep several pages published for different pipelines/branches.

To do that you need to copy your pages content (basically test report, or whatever needs to be published) to specific unique directory in public folder. For example, the name of the directory can be the id of pipeline (CI_PIPELINE_ID). So the path to pages sources would be like public/$CI_PIPELINE_ID/.

Then the whole public folder should be defined as artifacts with specific unique name (here again "$CI_PIPELINE_ID" can be used).

Unique name for artifacts is needed to not override the artifacts with the next pipeline execution (if name is not specified, the default name will be taken https://docs.gitlab.com/ee/ci/yaml/#artifactsname).

Then you can access the published report via the link:

https://yourGitlab/yourNamespace/yourProjectName/{CI_PIPELINE_ID}/index.html

, that means you can access all your saved reports by changing the pipeline id.

My example:

stages:
  - publish

cache:
  # Required to keep artifacts from old builds, e.g. from master
  paths:
    - public

pages:
  stage: publish
  script:
    - mkdir -p public/$CI_PIPELINE_ID
    - cp target/site/allure-maven-plugin/* public/$CI_PIPELINE_ID/ -R
  artifacts:
    name: "$CI_PIPELINE_ID"
    paths:
      - public
    expire_in: 5 days
  when: always
🌐
Lprp
lprp.fr › 2020 › 05 › static-files-publication-on-gitlab-pages
Static files publication on GitLab Pages | LPRP.fr
May 21, 2020 - GitLab Pages will serve files under the specific folder “public“. But having this folder in your repository will not be enough to activate GiLlab Pages. It requires basically to use CI/CD to deploy your content to GitLab Pages servers.
🌐
GitLab
gitlab.lexilogos.com › help › help
Public folder · Pages · Project · User · Help · GitLab
GitLab Pages supports only static sites. By default, Nuxt uses the public folder to store static assets.
🌐
GitLab
gitlab.com › gitlab.org › gitlab-pages › #668
Allow customizing the artifacts path ("public") in GitLab Pages (#668) · Issues · GitLab.org / gitlab-pages · GitLab
November 10, 2021 - Reasoning Currently GitLab Pages will only publish built files from a folder named public inside the project root.
🌐
GitLab
docs.gitlab.com › gitlab docs › use gitlab › deploy and release your application › gitlab pages
GitLab Pages | GitLab Docs
To use GitLab Pages, you must create a project in GitLab to upload your website’s files to. These projects can be either public, internal, or private. By default, GitLab deploys your website from a specific folder called public in your repository. You can also set a custom folder to be deployed ...
Find elsewhere
🌐
PRACE
repository.prace-ri.eu › help
Index · Pages · Project · User · Help · GitLab
To use GitLab Pages, you must create a project in GitLab to upload your website's files to. These projects can be either public, internal, or private. GitLab always deploys your website from a specific folder called public in your repository.
🌐
GitLab
gitlab.com › gitlab.org › issues › #345650
Gitlab Pages deploy wrong if my project exists public folder (#345650) · Issues · GitLab.org / GitLab · GitLab
November 14, 2021 - pages: stage: deploy script: - mkdir .public - cp -r * .public - mv .public public artifacts: paths: - public rules: - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
🌐
Fabiorosado
fabiorosado.dev › blog › setup-gitlab-pages
FabioRosado | How to setup Gitlab pages from a folder | Fabio Rosado
March 3, 2022 - The job deployed to Gitlab pages has to have the name pages. But another thing that you need to do is that the files are located in the public folder.
🌐
University of Toronto
microfluidics.utoronto.ca › help › help
Introduction · Pages · Project · User · Help · GitLab
Appended the pages.publish path automatically to artifacts:paths in GitLab 17.10. By default, Pages looks for a folder named public in your build files to publish it.
Top answer
1 of 3
2

If you are using managed GitLab (On GitLab.com), then this feature (multiple deployments) is not enabled in the free version (But it is in Premium, Ultimate versions), but if you have self-hosted GitLab then you should enabled this feature by administrator (It's disabled by-default).

Reference:

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

Select the Deploy -> Feature flags on the left side project's menu:

Set the pages_multiple_versions_setting feature flag:

Then you should configure the path prefix within pages.path_prefix scope in your .gitlab-ci.yml file. You can find examples and details on this GitHub page In your case you should extend your pages section with the following part:

pages:
  path_prefix: "$DEPLOY_DIR"

Note:

  • This feature is not production ready. You can follow the status of the feature in this ticket: https://gitlab.com/gitlab-org/gitlab/-/issues/422145
2 of 3
0

you can only have one pages site per GitLab project on GitLab.com free tier. Whatever you upload to the public folder in artefacts will override what was previously there hence why you are experiencing this behaviour.

You CAN do this however it is only for certain accounts as referenced here:

Tier: Premium, Ultimate Offering: SaaS, self-managed Status: Experiment

Read in full here.

🌐
Nira
nira.com › home › the ultimate manual to gitlab pages
The Ultimate Manual To GitLab Pages - Nira
May 3, 2022 - To use GitLab Pages, you have to ... in GitLab to upload your website files. GitLab Pages will always deploy your website from a specific folder called public in your repository....
🌐
GitLab
gitlab.lcqb.upmc.fr › help › user › project › pages › introduction.md
Introduction · Pages · Project · User · Help · GitLab
The public/ directory should contain all the static content of your website. Depending on how you plan to publish your website, the steps defined in the script parameter may differ.
🌐
Publii
getpublii.com › docs › host-static-website-gitlab-pages.html
How to create a static website using GitLab Pages (Full Guide)
August 8, 2024 - With this done you can click the ... will see the following file structure in your repository: public is a directory which contains all the website files....
🌐
GitHub
github.com › juliomrqz › statusfy › issues › 460
Gitlab Pages: /public cannot be used for the publicly present files. · Issue #460 · juliomrqz/statusfy
June 13, 2022 - Specifically, the issue is with the part where -d public is specified to replace /dist, as Gitlab requires that the deployment folder is named public, as such, the statusfy client errors out because it cannot create the distribution files in ...
Author: juliomrqz