diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 1aaa27fa906b0b6054f94612604cf723a4184aca..d8794348bfa7e5fb64eca82b839e80873dfcb548 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -41,6 +41,7 @@ setup:
     - find src/ -type f -name '*.html'
       -exec sed -i
         -e "s|%%BRANCH%%|${CI_COMMIT_BRANCH}|g"
+        -e "s|%%BASE_URL%%|${CI_PAGES_URL}/|g"
         -e "s|%%COMMIT_SHA%%|${CI_COMMIT_SHORT_SHA}|g"
         -e "s|%%COMMIT_TIMESTAMP%%|${CI_COMMIT_TIMESTAMP}|g"
         -e "s|%%JOB_ID%%|${CI_JOB_ID}|g"
diff --git a/src/cache-test.html b/src/cache-test.html
index a60c97dab8501d0603718e5d594ca5a830e9ee99..c4357328fdc250809905088fa1379e868b4578e4 100644
--- a/src/cache-test.html
+++ b/src/cache-test.html
@@ -2,9 +2,10 @@
 <html lang="en">
 <head>
   <meta charset="utf-8">
+  <base href="%%BASE_URL%%">
+  <title>Cache Test | %%PROJECT_TITLE%%</title>
   <meta name="viewport" content="width=device-width, initial-scale=1">
   <meta name="generator" content="GitLab Pages">
-  <title>Cache Test | %%PROJECT_TITLE%%</title>
   <link rel="shortcut icon" href="gitlab-favicon.png">
   <link rel="preload" href="style.css" as="style">
   <link rel="stylesheet" href="style.css">
diff --git a/src/index.html b/src/index.html
index 118ee3b24639243a7b9bee32dcae20c3f8b05bd2..368a6da28db357cf40261ced3afdaab447f9ccce 100644
--- a/src/index.html
+++ b/src/index.html
@@ -2,9 +2,10 @@
 <html lang="en">
 <head>
   <meta charset="utf-8">
+  <base href="%%BASE_URL%%">
+  <title>%%PROJECT_TITLE%%</title>
   <meta name="viewport" content="width=device-width, initial-scale=1">
   <meta name="generator" content="GitLab Pages">
-  <title>%%PROJECT_TITLE%%</title>
   <link rel="shortcut icon" href="gitlab-favicon.png">
   <link rel="preload" href="style.css" as="style">
   <link rel="stylesheet" href="style.css">
diff --git a/src/sub/index.html b/src/sub/index.html
index 6350dbdd7990bf484fe40a96040d1ca5190afaf4..4cf21a80a4efcc0cea25d3293ed17cc534cd3a29 100644
--- a/src/sub/index.html
+++ b/src/sub/index.html
@@ -2,18 +2,19 @@
 <html lang="en">
 <head>
   <meta charset="utf-8">
+  <base href="%%BASE_URL%%">
+  <title>Subdirectory | %%PROJECT_TITLE%%</title>
   <meta name="viewport" content="width=device-width, initial-scale=1">
   <meta name="generator" content="GitLab Pages">
-  <title>Subdirectory | %%PROJECT_TITLE%%</title>
-  <link rel="shortcut icon" href="../gitlab-favicon.png">
-  <link rel="preload" href="../style.css" as="style">
-  <link rel="stylesheet" href="../style.css">
+  <link rel="shortcut icon" href="gitlab-favicon.png">
+  <link rel="preload" href="style.css" as="style">
+  <link rel="stylesheet" href="style.css">
 </head>
 <body>
   <header>
-    <a href="../">Homepage</a>
-    <a href="../cache-test.html">Cache Test</a>
-    <a href="./">Subdirectory</a>
+    <a href="./">Homepage</a>
+    <a href="cache-test.html">Cache Test</a>
+    <a href="sub/">Subdirectory</a>
     <a href="%%PROJECT_URL%%">Repository</a>
   </header>
   <main>