From e02aea20eb1596a8a5c4dda8948b4781d0097c88 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 19 Nov 2025 06:42:06 +0530 Subject: [PATCH 1/5] Add `nav-external` class for external links --- layouts/partials/footer.html | 2 +- layouts/partials/navbar.html | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index de969b9d..ebccfc6a 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -16,7 +16,7 @@ {{- else }} - + {{ .title | safeHTML }} {{- end }} From 67125e05df24325de36b64a96c514f880f7740f4 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 19 Nov 2025 06:45:15 +0530 Subject: [PATCH 2/5] Add styling based on what PST does --- assets/theme-css/footer.css | 8 ++++++++ assets/theme-css/navbar.css | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/assets/theme-css/footer.css b/assets/theme-css/footer.css index 3947f421..2cdb13fe 100644 --- a/assets/theme-css/footer.css +++ b/assets/theme-css/footer.css @@ -39,6 +39,14 @@ color: var(--spht-color-link-hover); } +.footer-item a.nav-external::after { + font: var(--fa-font-solid); + content: "\f35d"; + font-size: 0.75em; + margin-left: 0.3em; + display: inline-block; +} + .footer-actions { max-width: 25vw; margin: 1.25rem 1.563rem; diff --git a/assets/theme-css/navbar.css b/assets/theme-css/navbar.css index 9e8eeafb..f7d1958d 100644 --- a/assets/theme-css/navbar.css +++ b/assets/theme-css/navbar.css @@ -42,6 +42,15 @@ a.navbar-item:hover, text-decoration-thickness: max(3px, 0.1875rem, 0.12em); } +a.navbar-item.nav-external::after, +.navbar-dropdown a.navbar-item.nav-external::after { + font: var(--fa-font-solid); + content: "\f35d"; + font-size: 0.75em; + margin-left: 0.3em; + display: inline-block; +} + .navbar-burger { font-family: inherit; font-size: 1em; From f805b17abbf2329b33b00c6ed9e321cdb928d9c0 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 19 Nov 2025 06:47:01 +0530 Subject: [PATCH 3/5] Add docs --- doc/content/user_guide/features.md | 42 ++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/doc/content/user_guide/features.md b/doc/content/user_guide/features.md index 69a841a0..a6569fe6 100644 --- a/doc/content/user_guide/features.md +++ b/doc/content/user_guide/features.md @@ -93,6 +93,48 @@ To use them elsewhere, e.g. in Hugo templates, we provide an `svg-icon` partial. {{ partial "svg-icon" "my-icon" }} ``` +## External links + +Links in the navbar and footer can be marked as external by adding `is_external: true`. This displays an external link indicator icon (↗) +next to the link text and opens the link in a new tab. + +### Navbar external links + +```yaml +params: + navbar: + - title: Documentation + url: /docs/ + - title: GitHub + url: https://github.com/your-org/your-repo + is_external: true + - title: More + sublinks: + - title: Internal Page + url: /internal/ + - title: External Resource + url: https://example.com + is_external: true +``` + +### Footer external links + +```yaml +params: + footer: + quicklinks: + column1: + title: "Links" + links: + - text: About + link: /about/ + - text: GitHub Repository + link: https://github.com/your-org/your-repo + is_external: true +``` + +The external link indicator automatically adapts to both light and dark colour modes. + ## Mermaid diagrams [Mermaid](https://mermaid.js.org/) diagrams are rendered from code blocks: From 827c76e98e6f687a47dc7324d2dfc2b7ae698b1d Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 19 Nov 2025 06:47:17 +0530 Subject: [PATCH 4/5] Add examples to theme navbar and footers --- doc/config.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/config.yaml b/doc/config.yaml index e4fca1e8..b9596100 100644 --- a/doc/config.yaml +++ b/doc/config.yaml @@ -41,6 +41,9 @@ params: url: /shortcodes/ - title: Examples url: /examples/ + - title: Repository + url: https://github.com/scientific-python/scientific-python-hugo-theme + is_external: true - title: More sublinks: - title: Dropdown item @@ -70,9 +73,11 @@ params: link: /about/ - text: Theme GitHub link: https://github.com/scientific-python/scientific-python-hugo-theme + is_external: true column2: links: - text: Scientific Python Forum link: https://discuss.scientific-python.org + is_external: true column3: links: From 8851a777226974fa4d74a316d31c5408d7ddb264 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 19 Nov 2025 06:49:22 +0530 Subject: [PATCH 5/5] Need more space for external SVGs in the footer --- assets/theme-css/footer.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/assets/theme-css/footer.css b/assets/theme-css/footer.css index 2cdb13fe..930ab562 100644 --- a/assets/theme-css/footer.css +++ b/assets/theme-css/footer.css @@ -39,6 +39,10 @@ color: var(--spht-color-link-hover); } +.footer-item a.nav-external { + white-space: nowrap; +} + .footer-item a.nav-external::after { font: var(--fa-font-solid); content: "\f35d";