diff --git a/gitlab/after_docs.sh b/gitlab/after_docs.sh
index 146f01578e6a5e71664bd82a03d02bf921cb5bec..73a037624bb88e0aed6b9d09f5c6aa0291b38784 100755
--- a/gitlab/after_docs.sh
+++ b/gitlab/after_docs.sh
@@ -1,8 +1,2 @@
 #!/usr/bin/env bash
 # Thu 22 Sep 2016 18:23:57 CEST
-
-# unset vars exported in before_docs.sh
-unset IS_MASTER
-unset MASTER_UPLOAD_PATH
-unset TAG_UPLOAD_PATH
-unset STABLE_UPLOAD_PATH
diff --git a/gitlab/before_docs.sh b/gitlab/before_docs.sh
index 0ca4790d2277012c74858dd442ac52146dc485e4..ca031af511ed7dc9fded8be01de9986daa693b32 100755
--- a/gitlab/before_docs.sh
+++ b/gitlab/before_docs.sh
@@ -3,52 +3,7 @@
 
 source $(dirname ${0})/functions.sh
 
-# decide whether this is master
-# assume it's being ran on master by default
-IS_MASTER=true
-# if its a tag build, it might not be master
-if [[ -n $CI_BUILD_TAG ]]; then
-  IS_MASTER=false
-  # fetch repo & check if tag came from master
-  git fetch origin
-  for p in $(git branch -a --quiet --contains tags/"$CI_BUILD_TAG"); do
-    [[ $p == 'remotes/origin/master' ]] && IS_MASTER=true
-  done
-fi
-
-# prefix differs between private & public repos
-if [[ "${VISIBILITY}" == "public" ]]; then
-  DOCS_SERVER_PREFIX="public-upload/$CI_PROJECT_PATH/docs"
-else
-  DOCS_SERVER_PREFIX="private-upload/$CI_PROJECT_PATH/docs"
-fi
-
-# define possible upload paths
-# folder for master branch
-MASTER_UPLOAD_PATH="$DOCS_SERVER_PREFIX/master/"
-# folder for a tag
-TAG_UPLOAD_PATH="$DOCS_SERVER_PREFIX/$CI_BUILD_TAG/"
-# folder for new stable version
-STABLE_UPLOAD_PATH="$DOCS_SERVER_PREFIX/stable/"
-
-# rm already existing folders if necessary
-# folder for HEAD of master
-if [[ $IS_MASTER == true ]]; then
-  dav_delete "$MASTER_UPLOAD_PATH"
-fi
-
-# upload to the tag folder if this build is tagged
-if [[ -n $CI_BUILD_TAG ]]; then
-  dav_delete "$TAG_UPLOAD_PATH"
-fi
-
-# upload to the stable folder if this build is tagged and on master
-if [[ -n $CI_BUILD_TAG && $IS_MASTER == true ]]; then
-  dav_delete "$STABLE_UPLOAD_PATH"
-fi
-
-# export vars for docs script to use
-export_env IS_MASTER
-export_env MASTER_UPLOAD_PATH
-export_env TAG_UPLOAD_PATH
-export_env STABLE_UPLOAD_PATH
+# Deletes all existing dav folders that will be overwritten
+for k in "${DOC_UPLOADS[@]}"; do
+  dav_delete "${k}"
+done
diff --git a/gitlab/docs.sh b/gitlab/docs.sh
index 0569ec7e8e2ae91b26cae0790035a7b48818b6b2..0f16afac02fca732574599e3306b11151f5cafd6 100755
--- a/gitlab/docs.sh
+++ b/gitlab/docs.sh
@@ -3,31 +3,7 @@
 
 source $(dirname ${0})/functions.sh
 
-check_env IS_MASTER
-check_env MASTER_UPLOAD_PATH
-check_env TAG_UPLOAD_PATH
-check_env STABLE_UPLOAD_PATH
-
-info=sphinx/.gitlab-ci.info
-
-echo "repo=${CI_PROJECT_PATH}" > ${info}
-echo "branch=${CI_BUILD_REF_NAME}" >> ${info}
-echo "tag=${CI_BUILD_TAG}" >> ${info}
-echo "build=${CI_BUILD_ID}" >> ${info}
-echo "commit=${CI_BUILD_REF}" >> ${info}
-echo "runner=${CI_RUNNER_DESCRIPTION}" >> ${info}
-
-# folder for HEAD of master
-if [[ $IS_MASTER == true ]]; then
-  dav_upload_folder sphinx "$MASTER_UPLOAD_PATH"
-fi
-
-# upload to the tag folder if this build is tagged
-if [[ -n $CI_BUILD_TAG ]]; then
-  dav_upload_folder sphinx "$TAG_UPLOAD_PATH"
-fi
-
-# upload to the stable folder if this build is tagged and on master
-if [[ -n $CI_BUILD_TAG && $IS_MASTER == true ]]; then
-  dav_upload_folder sphinx "$STABLE_UPLOAD_PATH"
-fi
+# Deletes all existing dav folders that will be overwritten
+for k in "${DOC_UPLOADS[@]}"; do
+  dav_upload_folder "${k}"
+done