From 088f874aa9b40fdd2ab56c204430d6029e2ffe45 Mon Sep 17 00:00:00 2001 From: Abdullah <89297042+AzazelSensei@users.noreply.github.com> Date: Tue, 22 Sep 2026 04:58:39 +0000 Subject: [PATCH 1/2] [GH-2426] Add a branded documentation 404 page Missing docs URLs currently hit Apache's default Not Found page. Replace the Material 404 template with a short page that links home, SedonaSpark, and SedonaDB, and publish it at the site root so the server can serve it. --- .github/workflows/docs.yml | 22 ++++++++++ docs-overrides/404.html | 40 +++++++++++++++++ docs-overrides/hooks/custom_404.py | 70 ++++++++++++++++++++++++++++++ docs-overrides/htaccess-root | 18 ++++++++ mkdocs.yml | 1 + 5 files changed, 151 insertions(+) create mode 100644 docs-overrides/404.html create mode 100644 docs-overrides/hooks/custom_404.py create mode 100644 docs-overrides/htaccess-root diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 854d820479c..9a701b2664b 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -146,6 +146,28 @@ jobs: else echo "Archived documentation already noindexed; nothing to commit." fi + - name: Publish root 404 page + # Missing URLs currently hit Apache httpd's default Not Found page + # because 404.html only lives under each mike version. Copy the + # branded page to the site root and set ErrorDocument so visitors + # actually see it. See GH-2426. + if: ${{ github.event_name != 'pull_request' && github.repository == 'apache/sedona' }} + run: | + if [[ ! -d website-branch ]]; then + git fetch origin website --depth=1 + git worktree add website-branch FETCH_HEAD + fi + git -C website-branch config user.name "github-actions[bot]" + git -C website-branch config user.email "41898282+github-actions[bot]@users.noreply.github.com" + cp website-branch/latest/404.html website-branch/404.html + cp docs-overrides/htaccess-root website-branch/.htaccess + git -C website-branch add 404.html .htaccess + if [[ -n "$(git -C website-branch status --porcelain)" ]]; then + git -C website-branch commit -m "Publish branded 404 page at the site root" + git -C website-branch push origin HEAD:website + else + echo "Root 404 page already current; nothing to commit." + fi - run: mkdir staging - run: cp -r site/* staging/ - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 diff --git a/docs-overrides/404.html b/docs-overrides/404.html new file mode 100644 index 00000000000..5c57832e3ab --- /dev/null +++ b/docs-overrides/404.html @@ -0,0 +1,40 @@ +{% extends "main.html" %} + +{% block htmltitle %} + Page not found – {{ config.site_name }} +{% endblock %} + +{% block extrahead %} +{{ super() }} + +{% endblock %} + +{% block content %} +{%- set cur_lang = config.theme.language if config.theme.language in ['en', 'zh'] else 'en' -%} +{%- set t = { + 'en': { + 'heading': 'Page not found', + 'body': 'This URL is not part of the Apache Sedona documentation. Try the home page, or search from the header.', + 'home': 'Home', + 'spark': 'SedonaSpark', + 'db': 'SedonaDB', + 'github': 'GitHub' + }, + 'zh': { + 'heading': '页面未找到', + 'body': '该网址不在 Apache Sedona 文档中。请返回首页,或使用页眉上的搜索。', + 'home': '首页', + 'spark': 'SedonaSpark', + 'db': 'SedonaDB', + 'github': 'GitHub' + } +}[cur_lang] -%} +

{{ t.heading }}

+

{{ t.body }}

+

+ {{ t.home }} + {{ t.spark }} + {{ t.db }} + {{ t.github }} +

+{% endblock %} diff --git a/docs-overrides/hooks/custom_404.py b/docs-overrides/hooks/custom_404.py new file mode 100644 index 00000000000..610fb515767 --- /dev/null +++ b/docs-overrides/hooks/custom_404.py @@ -0,0 +1,70 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +"""Keep the default-language 404 page and point Apache at it. + +mkdocs-static-i18n builds English then Chinese. The Chinese nested build +overwrites site/404.html, so /latest/404.html would otherwise ship in zh. +This hook restores the English page after every language has finished, and +writes a per-version .htaccess so missing URLs under that version use the +branded 404 instead of Apache's default Not Found page. +""" + +from pathlib import Path + +from mkdocs import plugins + +_DEFAULT_404 = None + +_HTACCESS = """\ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +ErrorDocument 404 /latest/404.html +""" + + +@plugins.event_priority(-110) +def on_post_build(config, **kwargs): + global _DEFAULT_404 + site_dir = Path(config.site_dir) + html = site_dir / "404.html" + i18n = config.plugins.get("i18n") + + if i18n is not None and i18n.building: + if config.theme.language == i18n.default_language and html.is_file(): + _DEFAULT_404 = html.read_bytes() + return + + if _DEFAULT_404 is not None: + html.write_bytes(_DEFAULT_404) + + (site_dir / ".htaccess").write_text(_HTACCESS, encoding="utf-8") diff --git a/docs-overrides/htaccess-root b/docs-overrides/htaccess-root new file mode 100644 index 00000000000..d1b2495527f --- /dev/null +++ b/docs-overrides/htaccess-root @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +ErrorDocument 404 /404.html diff --git a/mkdocs.yml b/mkdocs.yml index b3e1e58c24d..5c75d87f167 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -385,6 +385,7 @@ hooks: - docs-overrides/hooks/i18n_blog_passthrough.py - docs-overrides/hooks/i18n_sitemaps.py - docs-overrides/hooks/blog_star_cta.py + - docs-overrides/hooks/custom_404.py extra_css: - assets/stylesheets/extra.min.css extra_javascript: From c8e0b9e0b380202ed73c614c2b07138723284a9c Mon Sep 17 00:00:00 2001 From: Abdullah <89297042+AzazelSensei@users.noreply.github.com> Date: Tue, 22 Sep 2026 05:47:41 +0000 Subject: [PATCH 2/2] [GH-2426] Use a standalone root 404 page Drop the MkDocs template, i18n restoration hook, and copy from latest. Publish a static page at the site root instead. --- .github/workflows/docs.yml | 9 ++- docs-overrides/404.html | 40 ------------- docs-overrides/hooks/custom_404.py | 70 ---------------------- docs-overrides/root-404.html | 94 ++++++++++++++++++++++++++++++ mkdocs.yml | 1 - 5 files changed, 98 insertions(+), 116 deletions(-) delete mode 100644 docs-overrides/404.html delete mode 100644 docs-overrides/hooks/custom_404.py create mode 100644 docs-overrides/root-404.html diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 9a701b2664b..55024789b2d 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -147,10 +147,9 @@ jobs: echo "Archived documentation already noindexed; nothing to commit." fi - name: Publish root 404 page - # Missing URLs currently hit Apache httpd's default Not Found page - # because 404.html only lives under each mike version. Copy the - # branded page to the site root and set ErrorDocument so visitors - # actually see it. See GH-2426. + # Missing URLs currently hit Apache httpd's default Not Found page. + # Copy a standalone page (not generated by MkDocs) to the site root + # and set ErrorDocument so visitors actually see it. See GH-2426. if: ${{ github.event_name != 'pull_request' && github.repository == 'apache/sedona' }} run: | if [[ ! -d website-branch ]]; then @@ -159,7 +158,7 @@ jobs: fi git -C website-branch config user.name "github-actions[bot]" git -C website-branch config user.email "41898282+github-actions[bot]@users.noreply.github.com" - cp website-branch/latest/404.html website-branch/404.html + cp docs-overrides/root-404.html website-branch/404.html cp docs-overrides/htaccess-root website-branch/.htaccess git -C website-branch add 404.html .htaccess if [[ -n "$(git -C website-branch status --porcelain)" ]]; then diff --git a/docs-overrides/404.html b/docs-overrides/404.html deleted file mode 100644 index 5c57832e3ab..00000000000 --- a/docs-overrides/404.html +++ /dev/null @@ -1,40 +0,0 @@ -{% extends "main.html" %} - -{% block htmltitle %} - Page not found – {{ config.site_name }} -{% endblock %} - -{% block extrahead %} -{{ super() }} - -{% endblock %} - -{% block content %} -{%- set cur_lang = config.theme.language if config.theme.language in ['en', 'zh'] else 'en' -%} -{%- set t = { - 'en': { - 'heading': 'Page not found', - 'body': 'This URL is not part of the Apache Sedona documentation. Try the home page, or search from the header.', - 'home': 'Home', - 'spark': 'SedonaSpark', - 'db': 'SedonaDB', - 'github': 'GitHub' - }, - 'zh': { - 'heading': '页面未找到', - 'body': '该网址不在 Apache Sedona 文档中。请返回首页,或使用页眉上的搜索。', - 'home': '首页', - 'spark': 'SedonaSpark', - 'db': 'SedonaDB', - 'github': 'GitHub' - } -}[cur_lang] -%} -

{{ t.heading }}

-

{{ t.body }}

-

- {{ t.home }} - {{ t.spark }} - {{ t.db }} - {{ t.github }} -

-{% endblock %} diff --git a/docs-overrides/hooks/custom_404.py b/docs-overrides/hooks/custom_404.py deleted file mode 100644 index 610fb515767..00000000000 --- a/docs-overrides/hooks/custom_404.py +++ /dev/null @@ -1,70 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -"""Keep the default-language 404 page and point Apache at it. - -mkdocs-static-i18n builds English then Chinese. The Chinese nested build -overwrites site/404.html, so /latest/404.html would otherwise ship in zh. -This hook restores the English page after every language has finished, and -writes a per-version .htaccess so missing URLs under that version use the -branded 404 instead of Apache's default Not Found page. -""" - -from pathlib import Path - -from mkdocs import plugins - -_DEFAULT_404 = None - -_HTACCESS = """\ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -ErrorDocument 404 /latest/404.html -""" - - -@plugins.event_priority(-110) -def on_post_build(config, **kwargs): - global _DEFAULT_404 - site_dir = Path(config.site_dir) - html = site_dir / "404.html" - i18n = config.plugins.get("i18n") - - if i18n is not None and i18n.building: - if config.theme.language == i18n.default_language and html.is_file(): - _DEFAULT_404 = html.read_bytes() - return - - if _DEFAULT_404 is not None: - html.write_bytes(_DEFAULT_404) - - (site_dir / ".htaccess").write_text(_HTACCESS, encoding="utf-8") diff --git a/docs-overrides/root-404.html b/docs-overrides/root-404.html new file mode 100644 index 00000000000..26d1f69aae2 --- /dev/null +++ b/docs-overrides/root-404.html @@ -0,0 +1,94 @@ + + + + + + + + Page not found – Apache Sedona + + + +
+

Page not found

+

+ This URL is not part of the Apache Sedona documentation. + Try the home page, or jump to SedonaSpark or SedonaDB. +

+ +
+ + + diff --git a/mkdocs.yml b/mkdocs.yml index 5c75d87f167..b3e1e58c24d 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -385,7 +385,6 @@ hooks: - docs-overrides/hooks/i18n_blog_passthrough.py - docs-overrides/hooks/i18n_sitemaps.py - docs-overrides/hooks/blog_star_cta.py - - docs-overrides/hooks/custom_404.py extra_css: - assets/stylesheets/extra.min.css extra_javascript: