From c4d3cea4c65df049815c520e3ad7b5f4d6955be4 Mon Sep 17 00:00:00 2001 From: rohan-019 Date: Thu, 7 Aug 2025 12:37:37 +0530 Subject: [PATCH 1/4] feat: route knative docs base URL from knative.dev/docs to knative.dev - Updated base URL configuration from knative.dev/docs to knative.dev - Added comprehensive 301 redirects for smooth transition - Updated blog configuration to point to new base URL - Ensures backward compatibility with existing links and search results This change routes the base URL for Knative docs to knative.dev instead of knative.dev/docs, while maintaining backward compatibility through proper redirects that won't break search results or existing links. --- blog/mkdocs.yml | 2 +- mkdocs.yml | 2 +- netlify.toml | 12 ++++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/blog/mkdocs.yml b/blog/mkdocs.yml index 887e5637ebb..74e82447d11 100644 --- a/blog/mkdocs.yml +++ b/blog/mkdocs.yml @@ -79,7 +79,7 @@ plugins: copyright: "Copyright © 2024 The Knative Authors" extra: - homepage: https://knative.dev/docs + homepage: https://knative.dev # social: # - icon: fontawesome/brands/twitter # link: https://twitter.com/KnativeProject diff --git a/mkdocs.yml b/mkdocs.yml index 9ed90642041..05b52bebf30 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,7 +1,7 @@ INHERIT: config/nav.yml site_name: Knative -site_url: https://knative.dev/docs +site_url: https://knative.dev site_description: Knative Documentation extra_css: - stylesheets/extra.css diff --git a/netlify.toml b/netlify.toml index 57eb5067f5c..9b3fa84689b 100644 --- a/netlify.toml +++ b/netlify.toml @@ -31,3 +31,15 @@ from = "/docs/help/contributor/*" to = "https://github.com/knative/docs/blob/main/contribute-to-docs/README.md" status = 301 + +# Redirect from /docs/* to root to handle the base URL change +[[redirects]] + from = "/docs/*" + to = "/:splat" + status = 301 + +# Ensure the root path serves the docs +[[redirects]] + from = "/" + to = "/index.html" + status = 200 From 2c79dcafd3af132b73858689ce2c8e279d59fba1 Mon Sep 17 00:00:00 2001 From: rohan-019 Date: Sun, 17 Aug 2025 22:46:12 +0530 Subject: [PATCH 2/4] Fix base URL change --- hack/build.sh | 30 ++++++------------------------ mkdocs.yml | 2 +- netlify.toml | 8 ++++---- 3 files changed, 11 insertions(+), 29 deletions(-) diff --git a/hack/build.sh b/hack/build.sh index 20a805c7c9f..361747958f2 100755 --- a/hack/build.sh +++ b/hack/build.sh @@ -27,7 +27,7 @@ set -x # 1) Make a release-NN branch as normal. # 2) Update VERSIONS below (on main) to include the new version, and remove the oldest # Order matters :-), Most recent first. -VERSIONS=("1.19" "1.18" "1.17") # Docs version, results in the url e.g. knative.dev/docs-1.9/.. +VERSIONS=("1.19" "1.18" "1.17") # Docs version, results in the url e.g. knative.dev/v1.9-docs/.. # 4) PR the result to main. # 5) Party. @@ -41,8 +41,8 @@ readonly SITE=$PWD/site rm -rf site/ if [ "$BUILD_VERSIONS" == "no" ]; then - # HEAD to /docs if we're not doing versioning. - mkdocs build -f mkdocs.yml -d site/docs + # HEAD to root if we're not doing versioning. + mkdocs build -f mkdocs.yml -d site else # Versioning: pre-release (HEAD): docs => development/ cp -r . $TEMP/docs-main @@ -50,7 +50,7 @@ else curl -f -L --show-error https://raw.githubusercontent.com/knative/eventing/main/docs/eventing-api.md -s > "$TEMP/docs-main/docs/eventing/reference/eventing-api.md" pushd "$TEMP/docs-main"; mkdocs build -f mkdocs.yml -d $SITE/development; popd - # Latest release branch to /docs + # Latest release branch to root git clone --depth 1 -b ${DOCS_BRANCHES[0]} https://github.com/${GIT_SLUG} "$TEMP/docs-$latest" if [ ${latest#*1.} -gt 6 ]; then @@ -61,7 +61,7 @@ else curl -f -L --show-error https://raw.githubusercontent.com/knative/eventing/${DOCS_BRANCHES[0]}/docs/eventing-api.md -s > "$TEMP/docs-$latest/docs/reference/api/eventing-api.md" fi - pushd "$TEMP/docs-$latest"; KNATIVE_VERSION="${VERSIONS[0]}.0" SAMPLES_BRANCH="${DOCS_BRANCHES[0]}" mkdocs build -d $SITE/docs; popd + pushd "$TEMP/docs-$latest"; KNATIVE_VERSION="${VERSIONS[0]}.0" SAMPLES_BRANCH="${DOCS_BRANCHES[0]}" mkdocs build -d $SITE; popd # Previous release branches release-$version to /v$version-docs versionjson="" @@ -107,25 +107,7 @@ cp golang/*.html site/golang/ cat golang/_redirects >> site/_redirects -# Home page is served from docs, so add a redirect. -cat << EOF > site/index.html - - - - - Redirecting - - - - - Redirecting to docs/... - - -EOF +# Home page is now served directly from root, no redirect needed # Clean up rm -rf $TEMP diff --git a/mkdocs.yml b/mkdocs.yml index 05b52bebf30..c3de268935c 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -7,7 +7,7 @@ extra_css: - stylesheets/extra.css repo_url: https://github.com/knative/docs -edit_uri: edit/main/docs +edit_uri: edit/main theme: name: material diff --git a/netlify.toml b/netlify.toml index 9b3fa84689b..2b6f3921b86 100644 --- a/netlify.toml +++ b/netlify.toml @@ -38,8 +38,8 @@ to = "/:splat" status = 301 -# Ensure the root path serves the docs +# Redirect old /docs path to root [[redirects]] - from = "/" - to = "/index.html" - status = 200 + from = "/docs" + to = "/" + status = 301 From c1e5eab9f3266945f83900f0e1e0bab80f16ba41 Mon Sep 17 00:00:00 2001 From: rohan-019 Date: Fri, 5 Sep 2025 17:50:58 +0530 Subject: [PATCH 3/4] Update url structure Signed-off-by: rohan-019 --- hack/build.sh | 76 ++++++++++++++++++----------------------- netlify.toml | 95 ++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 115 insertions(+), 56 deletions(-) diff --git a/hack/build.sh b/hack/build.sh index 361747958f2..9964e993df0 100755 --- a/hack/build.sh +++ b/hack/build.sh @@ -41,55 +41,45 @@ readonly SITE=$PWD/site rm -rf site/ if [ "$BUILD_VERSIONS" == "no" ]; then - # HEAD to root if we're not doing versioning. + # Build to root if we're not doing versioning mkdocs build -f mkdocs.yml -d site else - # Versioning: pre-release (HEAD): docs => development/ - cp -r . $TEMP/docs-main + # Build latest version to /docs + cp -r . "$TEMP/docs-main" curl -f -L --show-error https://raw.githubusercontent.com/knative/serving/main/docs/serving-api.md -s > "$TEMP/docs-main/docs/serving/reference/serving-api.md" curl -f -L --show-error https://raw.githubusercontent.com/knative/eventing/main/docs/eventing-api.md -s > "$TEMP/docs-main/docs/eventing/reference/eventing-api.md" - pushd "$TEMP/docs-main"; mkdocs build -f mkdocs.yml -d $SITE/development; popd - - # Latest release branch to root - git clone --depth 1 -b ${DOCS_BRANCHES[0]} https://github.com/${GIT_SLUG} "$TEMP/docs-$latest" - - if [ ${latest#*1.} -gt 6 ]; then - curl -f -L --show-error https://raw.githubusercontent.com/knative/serving/${DOCS_BRANCHES[0]}/docs/serving-api.md -s > "$TEMP/docs-$latest/docs/serving/reference/serving-api.md" - curl -f -L --show-error https://raw.githubusercontent.com/knative/eventing/${DOCS_BRANCHES[0]}/docs/eventing-api.md -s > "$TEMP/docs-$latest/docs/eventing/reference/eventing-api.md" - else - curl -f -L --show-error https://raw.githubusercontent.com/knative/serving/${DOCS_BRANCHES[0]}/docs/serving-api.md -s > "$TEMP/docs-$latest/docs/reference/api/serving-api.md" - curl -f -L --show-error https://raw.githubusercontent.com/knative/eventing/${DOCS_BRANCHES[0]}/docs/eventing-api.md -s > "$TEMP/docs-$latest/docs/reference/api/eventing-api.md" - fi - - pushd "$TEMP/docs-$latest"; KNATIVE_VERSION="${VERSIONS[0]}.0" SAMPLES_BRANCH="${DOCS_BRANCHES[0]}" mkdocs build -d $SITE; popd - - # Previous release branches release-$version to /v$version-docs - versionjson="" + + # Create docs directory structure + mkdir -p "$SITE/docs" + + # Build latest docs to /docs + pushd "$TEMP/docs-main" + KNATIVE_VERSION="${VERSIONS[0]}.0" SAMPLES_BRANCH="${DOCS_BRANCHES[0]}" mkdocs build -d "$SITE/docs" + popd + + # Build versioned docs to /vX.Y-docs/ for i in "${!previous[@]}"; do - version=${previous[$i]} - versionjson+="{\"version\": \"v$version-docs\", \"title\": \"v$version\", \"aliases\": [\"\"]}," - - echo "Building for previous version $version" - git clone --depth 1 -b ${DOCS_BRANCHES[$i+1]} https://github.com/${GIT_SLUG} "$TEMP/docs-$version" - if [ ${version#*1.} -gt 6 ]; then - curl -f -L --show-error https://raw.githubusercontent.com/knative/serving/${DOCS_BRANCHES[i+1]}/docs/serving-api.md -s > "$TEMP/docs-$version/docs/serving/reference/serving-api.md" - curl -f -L --show-error https://raw.githubusercontent.com/knative/eventing/${DOCS_BRANCHES[i+1]}/docs/eventing-api.md -s > "$TEMP/docs-$version/docs/eventing/reference/eventing-api.md" - else - curl -f -L --show-error https://raw.githubusercontent.com/knative/serving/${DOCS_BRANCHES[i+1]}/docs/serving-api.md -s > "$TEMP/docs-$version/docs/reference/api/serving-api.md" - curl -f -L --show-error https://raw.githubusercontent.com/knative/eventing/${DOCS_BRANCHES[i+1]}/docs/eventing-api.md -s > "$TEMP/docs-$version/docs/reference/api/eventing-api.md" - fi - pushd "$TEMP/docs-$version"; KNATIVE_VERSION="${VERSIONS[i+1]}.0" SAMPLES_BRANCH="${DOCS_BRANCHES[i+1]}" VERSION_WARNING=true mkdocs build -d "$SITE/v$version-docs"; popd - + version="${previous[$i]}" + branch="${DOCS_BRANCHES[$((i+1))]}" + + git clone --depth 1 -b "$branch" "https://github.com/$GIT_SLUG" "$TEMP/docs-$version" + + # Copy non-versioned content from main branch + mkdir -p "$TEMP/docs-$version/docs/about" + cp -r "$TEMP/docs-main/docs/about" "$TEMP/docs-$version/docs/" + mkdir -p "$TEMP/docs-$version/docs/community" + cp -r "$TEMP/docs-main/docs/community" "$TEMP/docs-$version/docs/" + + pushd "$TEMP/docs-$version" + KNATIVE_VERSION="$version.0" SAMPLES_BRANCH="$branch" mkdocs build -d "$SITE/v$version-docs" + popd done - - # Set up the version file to point to the built docs. - cat << EOF > $SITE/versions.json - [ - {"version": "docs", "title": "v$latest", "aliases": [""]}, - $versionjson - {"version": "development", "title": "(Pre-release)", "aliases": [""]} - ] -EOF + + # Move non-versioned content to /docs + mkdir -p "$SITE/docs/about" + cp -r "$TEMP/docs-main/docs/about" "$SITE/docs/" + mkdir -p "$SITE/docs/community" + cp -r "$TEMP/docs-main/docs/community" "$SITE/docs/" fi # Create the blog diff --git a/netlify.toml b/netlify.toml index 2b6f3921b86..af614f78e9c 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,12 +1,13 @@ # Settings in the [build] context are global and are applied to all contexts # unless otherwise overridden by more specific contexts. [build] - command = "./hack/build.sh" + command = "hack/build.sh" publish = "site" [build.environment] - NODE_VERSION= "14" - PYTHON_VERSION = "3.8" + PYTHON_VERSION = "3.9" + NODE_VERSION = "16" + NPM_VERSION = "8.5.5" # Deploy Preview context: all deploys generated from a pull/merge request will # inherit these settings. @@ -17,29 +18,97 @@ [context.deploy-preview.environment] BUILD_VERSIONS="no" +# Handle versioned docs [[redirects]] - from = "/contributing/" + from = "/v:version-docs/*" + to = "/v:version-docs/:splat" + status = 200 + +# Redirect old versioned docs to new paths +[[redirects]] + from = "/docs-:version/*" + to = "/v:version-docs/:splat" + status = 301 + +# Redirect root to /docs for the latest version +[[redirects]] + from = "/" + to = "/docs" + status = 200 + +# Handle /docs paths +[[redirects]] + from = "/docs" + to = "/docs/" + status = 301 + +[[redirects]] + from = "/docs/*" + to = "/docs/:splat" + status = 200 + +# Handle old about and community URLs (root level to /docs/) +[[redirects]] + from = "/about" + to = "/docs/about/" + status = 301 + +[[redirects]] + from = "/about/*" + to = "/docs/about/:splat" + status = 301 + +[[redirects]] + from = "/community" to = "/docs/community/" status = 301 [[redirects]] from = "/community/*" - to = "/docs/community/" + to = "/docs/community/:splat" status = 301 +# Handle blog URLs [[redirects]] - from = "/docs/help/contributor/*" - to = "https://github.com/knative/docs/blob/main/contribute-to-docs/README.md" + from = "/blog/*" + to = "/blog/:splat" + status = 200 + +# Handle old development URLs +[[redirects]] + from = "/development/*" + to = "/docs/:splat" status = 301 -# Redirect from /docs/* to root to handle the base URL change +# Handle old API reference URLs [[redirects]] - from = "/docs/*" - to = "/:splat" + from = "/reference/api/*" + to = "/docs/reference/api/:splat" status = 301 -# Redirect old /docs path to root +# Handle old serving and eventing reference URLs [[redirects]] - from = "/docs" - to = "/" + from = "/serving/reference/*" + to = "/docs/serving/reference/:splat" + status = 301 + +[[redirects]] + from = "/eventing/reference/*" + to = "/docs/eventing/reference/:splat" + status = 301 + +# Keep existing contributor redirects +[[redirects]] + from = "/contributing/" + to = "/docs/community/" + status = 301 + +[[redirects]] + from = "/help/contributing/" + to = "https://github.com/knative/docs/blob/main/contribute-to-docs/README.md" + status = 301 + +[[redirects]] + from = "/docs/help/contributor/*" + to = "https://github.com/knative/docs/blob/main/contribute-to-docs/README.md" status = 301 From 1d741635d79257a12b2ae5fa9df19261690ea3dc Mon Sep 17 00:00:00 2001 From: rohan-019 Date: Sat, 6 Sep 2025 11:47:06 +0530 Subject: [PATCH 4/4] Fix build script and navigation for proper URL structure - Restore version JSON block for version picker functionality - Stop copying /about and /community into versioned builds - Restore API reference curl fetches for serving-api.md and eventing-api.md - Restore /development build step - Copy index.html and sitemap.xml to root after build - Update navigation to point to correct paths (root vs versioned) - Fix top-nav links to use proper URL structure --- config/nav.yml | 14 ------------- hack/build.sh | 36 ++++++++++++++++++++++++---------- overrides/partials/header.html | 4 ++-- 3 files changed, 28 insertions(+), 26 deletions(-) diff --git a/config/nav.yml b/config/nav.yml index bcd694b8e1c..088ed492d80 100644 --- a/config/nav.yml +++ b/config/nav.yml @@ -349,17 +349,3 @@ nav: - Verifying Knative Binaries: reference/security/verifying-cli.md - Release notes: reference/relnotes/README.md - Blog: /blog/ - - About: - - Testimonials: about/testimonials.md - - Case studies: - - List of Case Studies: about/case-studies/README.md - - deepc: about/case-studies/deepc.md - - IBM: about/case-studies/ibm.md - - Outfit7: about/case-studies/outfit7.md - - Puppet: about/case-studies/puppet.md - - PNC Bank: about/case-studies/pnc.md - - SVA: about/case-studies/sva.md - - Community: - - How To Get Involved: community/README.md - - Contribute to Knative: community/contributing.md - - Community Rules and Practices: community/governance.md diff --git a/hack/build.sh b/hack/build.sh index 9964e993df0..45e793f4355 100755 --- a/hack/build.sh +++ b/hack/build.sh @@ -64,22 +64,38 @@ else git clone --depth 1 -b "$branch" "https://github.com/$GIT_SLUG" "$TEMP/docs-$version" - # Copy non-versioned content from main branch - mkdir -p "$TEMP/docs-$version/docs/about" - cp -r "$TEMP/docs-main/docs/about" "$TEMP/docs-$version/docs/" - mkdir -p "$TEMP/docs-$version/docs/community" - cp -r "$TEMP/docs-main/docs/community" "$TEMP/docs-$version/docs/" + # Fetch API reference docs for versioned builds + curl -f -L --show-error https://raw.githubusercontent.com/knative/serving/$branch/docs/serving-api.md -s > "$TEMP/docs-$version/docs/serving/reference/serving-api.md" + curl -f -L --show-error https://raw.githubusercontent.com/knative/eventing/$branch/docs/eventing-api.md -s > "$TEMP/docs-$version/docs/eventing/reference/eventing-api.md" pushd "$TEMP/docs-$version" KNATIVE_VERSION="$version.0" SAMPLES_BRANCH="$branch" mkdocs build -d "$SITE/v$version-docs" popd done - # Move non-versioned content to /docs - mkdir -p "$SITE/docs/about" - cp -r "$TEMP/docs-main/docs/about" "$SITE/docs/" - mkdir -p "$SITE/docs/community" - cp -r "$TEMP/docs-main/docs/community" "$SITE/docs/" + # Build development site + pushd "$TEMP/docs-main" + KNATIVE_VERSION="${VERSIONS[0]}.0" SAMPLES_BRANCH="${DOCS_BRANCHES[0]}" mkdocs build -f mkdocs.yml -d "$SITE/development" + popd + + # Move non-versioned content to root level + mkdir -p "$SITE/about" + cp -r "$TEMP/docs-main/docs/about" "$SITE/" + mkdir -p "$SITE/community" + cp -r "$TEMP/docs-main/docs/community" "$SITE/" + + # Copy index.html and sitemap.xml to root + cp "$SITE/docs/index.html" "$SITE/" + cp "$SITE/docs/sitemap.xml" "$SITE/" + + # Create version JSON for version picker + versionjson="" + for i in "${!previous[@]}"; do + version=${previous[$i]} + versionjson+="{\"version\": \"v$version-docs\", \"title\": \"v$version\", \"aliases\": [\"\"]}," + done + versionjson="[{\"version\": \"docs\", \"title\": \"latest\", \"aliases\": [\"\"]},$versionjson]" + echo "$versionjson" > "$SITE/versions.json" fi # Create the blog diff --git a/overrides/partials/header.html b/overrides/partials/header.html index 380150f0139..be9a743dc26 100644 --- a/overrides/partials/header.html +++ b/overrides/partials/header.html @@ -97,7 +97,7 @@
  • - + About
  • @@ -107,7 +107,7 @@
  • - + Community