diff --git a/.gitignore b/.gitignore
index 97cc35437d998..06c01bc160dea 100644
--- a/.gitignore
+++ b/.gitignore
@@ -38,3 +38,6 @@ go/**
# archived site version
archived_version
+
+# Local Netlify folder
+.netlify
diff --git a/data/versions.yml b/data/versions.yml
index f7d6363f23c8e..246accedbdc70 100644
--- a/data/versions.yml
+++ b/data/versions.yml
@@ -2,4 +2,4 @@
main: "1.26"
# The version of Istio currently documented in preliminary.istio.io
-preliminary: "1.27"
+preliminary: "1.27"
\ No newline at end of file
diff --git a/layouts/partials/header.html b/layouts/partials/header.html
index 0261274a9050b..ac0df479f1cfb 100644
--- a/layouts/partials/header.html
+++ b/layouts/partials/header.html
@@ -1,6 +1,17 @@
{{ $home := .Site.GetPage "home" }}
-{{ $section := .Section }}
-{{ $current := . }}
+
+{{/* --- Version Logic --- */}}
+{{ $mainVersionFromYaml := site.Data.versions.main }}
+{{ $currentBuildVersionId := .Site.Params.currentVersionId | default $mainVersionFromYaml }}
+{{ $isLatestBuild := eq $currentBuildVersionId $mainVersionFromYaml }}
+{{ $isDocsPage := eq .Section "docs" }}
+
+{{ $currentPathSegmentForJS := "" }}
+{{ if $isLatestBuild }}
+ {{ $currentPathSegmentForJS = "latest" }}
+{{ else }}
+ {{ $currentPathSegmentForJS = printf "v%s" $currentBuildVersionId }}
+{{ end }}
+
+
\ No newline at end of file