Custom GitLab Pages domain for group with subdirectories for repositories

We have configured a custom domain (let’s say group.example.com) for GitLab Pages for our group, by creating a repository named groupname.gitlab.io.

I want to access the GitLab Pages of subgroups/projects via the subdirectory.
For example: let’s assume theres a repository called gitlab.com/groupname/somesub/somerepo, then I would expect the page to be visible at group.example.com/somesub/somerepo.
Unfortunately this does not seem to work.

How do I set this up?

Note that we are on GitLab.com and I have a similar setup working on GitHub.
I was expecting the GitLab Pages to have the same feature, but I’m not so sure about it now.

I’m afraid this is one of those things that is just a little annoying, not least because you can’t (yet) do this with the predefined CI variables.

What you want is something like this for review apps if you are using them:

deploy:review:
    stage: deploy
    image: ...
    script:
        # Write HTML to public/
        - ...
    artifacts:
        paths:
            - public
        expire_in: 1 week
    rules:
        - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
          when: never
        - when: always
    environment:
        name: review/$CI_COMMIT_BRANCH
        url: "https://GROUP.gitlab.io/-/SUBGROUP/$CI_PROJECT_NAME/-/jobs/$CI_JOB_ID/artifacts/public/index.html"
        auto_stop_in: 1 week

And something like this for your production release:

pages:  # Job MUST have this name
    stage: deploy
    image: ...
    script:
        # Write HTML to public/
        - ...
    artifacts:
        paths:
            - public
    rules:
        - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
          when: always
        - when: never
    environment:
        name: production
        url: https://GROUP.gitlab.io/SUBGROUP/$CI_PROJECT_NAME

HTH,

Sarah

Thanks for your reply.

I’m not sure if this really solves my “problem”.

I have multiple repositories using GitLab Pages in a single Group (.
I have setup a custom domain name for the Group (by adding a groupname.gitlab.io repository in the top of the Group). Let’s say that this custom domain name is group.example.com. This is now publishing a dummy website.

Now I want all the other repositories in this group that publish GitLab Pages, to make them accessible in a “sub path” of the custom domain name setup for the Group.
For instance, within the group we have a subgroup topsecret with two repositories in it (let’s say area51 and xfiles) that both publish GitLab Pages.
Normally these are already available via groupname.gitlab.io/topsecret/area51 and groupname.gitlab.io/topsecret/xfiles.
Instead, I want them to be available on group.example.com/topsecret/area51 and group.example.com/topsecret/xfiles.

I’m pretty sure I’ve configured something like this on GitHub previously, but I’m a bit lost how to achieve this on GitLab.

Right, sorry, I misread your original question.

So, I think what you want to do is to either:

  1. have the subgroup repositories trigger a child pipeline in the groupname.gitlab.io repo, pass the built subfolder to the child pipeline, which would merge the subfolder into the whole site. This issue looks like it may cause you problems, but I see there are docs which suggest that artifacts can be passed between parent/child pipelines.
  2. Alternatively, the groupname.gitlab.io repo could have a scheduled pipeline which clones the sugroup repos, builds their subfolders, and puts the whole site together. This option is a bit unwieldy, and will become more so as you add more subgroup repos.
1 Like