diff --git a/_layouts/docs.html b/_layouts/docs.html
index 548c7554c0..e14b9489d4 100644
--- a/_layouts/docs.html
+++ b/_layouts/docs.html
@@ -312,7 +312,13 @@
// See js/archive.js and js/docs.js for logic relating to this
var isArchive = true;
var dockerVersion = 'v{{ site.docker_ce_stable_version }}';
- var pageURL = '{{ page.url }}';
+ // In archives, we need to know the page root and we get it from JEKYLL_ENV in the jekyll build command
+ var jekyllEnv = '{{ jekyll.environment }}';
+ // If unset (in non-archive branches), defaults to "development". In that case, reset it to empty
+ if (jekyllEnv == 'development') {
+ jekyllEnv = '';
+ }
+ var pageURL = jekyllEnv + '{{ page.url }}';