diff --git a/_templates/layout.html b/_templates/layout.html
index 8f360cf4172..ec144f52c32 100644
--- a/_templates/layout.html
+++ b/_templates/layout.html
@@ -3,8 +3,8 @@
{% block relbar1 %}
-
{%- if branch == 'main' %}
+
DOCS PREVIEW
{%- endif %}
diff --git a/conf.py b/conf.py
index 3a1b9f30788..b5d60fdf684 100644
--- a/conf.py
+++ b/conf.py
@@ -11,7 +11,7 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
-import sys, os, shutil
+import sys, os
import inspect
from unittest.mock import MagicMock #py3 only
@@ -243,8 +243,8 @@ def __getattr__(cls, name):
html_theme = "classic"
# Add the branch name as a variable that can be used in templates
-# this can be set as a sphinx-build option using `-A BRANCH=main`
-html_context = {'branch': release}
+# Defaults to 'local'if GIT_BRANCH isn't set (e.g. local builds)
+html_context = {'branch': os.environ.get('GIT_BRANCH', 'local')}
# linkcheck options
# -----------------