Skip to content

Commit b0e35fc

Browse files
committed
Old URL redirect page
1 parent f4fbd72 commit b0e35fc

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

.github/workflows/deploy-workshop.yml

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,51 @@ jobs:
8080
8181
- name: Build Hugo site
8282
run: |
83-
hugo --minify --destination "public" --baseURL "${{ steps.bumpversion.outputs.base_url }}observability-workshop" --noChmod
83+
hugo --minify --destination "public" --baseURL "${{ steps.bumpversion.outputs.base_url }}observability-workshop" --noChmod --cacheDir /tmp/hugo_cache
84+
85+
- name: Create redirect handler for old URLs
86+
run: |
87+
cat > public/404.html << 'EOF'
88+
<!DOCTYPE html>
89+
<html lang="en">
90+
<head>
91+
<meta charset="utf-8">
92+
<title>Redirecting...</title>
93+
<script>
94+
// Handle redirects from old versioned URLs to new root URLs
95+
(function() {
96+
var path = window.location.pathname;
97+
98+
// Match /latest/ or /v{version}/ patterns (e.g., /latest/en/index.html or /v6.13/en/index.html)
99+
var versionPattern = /^\/(latest|v[\d.]+)\/(.*)/;
100+
var match = path.match(versionPattern);
101+
102+
if (match) {
103+
// Extract the path after the version (e.g., "en/index.html")
104+
var newPath = '/' + match[2];
105+
106+
// Preserve query string and hash if present
107+
var newUrl = window.location.origin + '/observability-workshop' + newPath + window.location.search + window.location.hash;
108+
109+
// Redirect to new URL
110+
window.location.replace(newUrl);
111+
} else {
112+
// If no version pattern matched, show a friendly 404 message
113+
document.write('<h1>404 - Page Not Found</h1>');
114+
document.write('<p>The page you are looking for does not exist.</p>');
115+
document.write('<p>Visit the <a href="/observability-workshop/">Splunk Observability Workshop homepage</a>.</p>');
116+
}
117+
})();
118+
</script>
119+
<noscript>
120+
<meta http-equiv="refresh" content="0; url=/observability-workshop/">
121+
</noscript>
122+
</head>
123+
<body>
124+
<p>Redirecting... If you are not redirected, <a href="/observability-workshop/">click here</a>.</p>
125+
</body>
126+
</html>
127+
EOF
84128
85129
- name: Deploy to GitHub Pages
86130
uses: peaceiris/actions-gh-pages@v3

0 commit comments

Comments
 (0)