diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 0852bbaa5e63ed6ceae1fc8ddad79db80d9fc16a..0d02e703beba9f35e9c8085eb9f6260da702357f 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -76,16 +76,13 @@ trigger_build:
 
 # Build the sphinx documentation and make it ready for deployment by Gitlab Pages
 # Special job for serving a static website. See https://docs.gitlab.com/ee/ci/yaml/README.html#pages
-pages:
+pages_prepare: &pages_prepare
   tags: [ cached-dind ]
   stage: deploy
   only:
     refs:
       - /^release-.*$/i
-      - master
-    variables:
-      # run pages only on gitlab.com
-      - $CI_SERVER_HOST == "gitlab.com"
+      - f-doc-structure
   script:
     - echo "Deploying"
     - make doc
@@ -93,3 +90,8 @@ pages:
   artifacts:
     paths:
       - public
+pages:
+  <<: *pages_prepare
+  only:
+    refs:
+      - main