diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index b04aa8a487ea0b54d040c00b5451de72538f0859..6ac69b740a54a17fc241fee31374f761bc7f2f52 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -4,7 +4,7 @@ pages:
   tags:
   - docker-amd64
   script:
-  - sphinx-build -b html . public
+  - "./gitlab-build.sh"
   artifacts:
     paths:
     - public
\ No newline at end of file
diff --git a/gitlab-build.sh b/gitlab-build.sh
new file mode 100644
index 0000000000000000000000000000000000000000..d20f6c4a90b9fc90a104285ead9591fec402f714
--- /dev/null
+++ b/gitlab-build.sh
@@ -0,0 +1,22 @@
+#!/bin/bash -xe
+mkdir -p public
+
+echo "**** Updating $PAGES_URL/$VER_DIR ****"
+echo "**** env ****"
+env
+
+# Clean build directory
+make clean BUILDDIR=public
+
+# Render HTML
+make html BUILDDIR=public
+mv public/html/* public/
+
+# Render PDF
+make latexpdf BUILDDIR=public/
+mv public/latex/*.pdf public/
+
+# Cleanup
+echo "**** cleanup ****"
+rm -rf public/doctrees
+rm -rf public/latex
\ No newline at end of file