Skip to content

Commit 13a6e7c

Browse files
fixes to url contetxt
1 parent cafe3a1 commit 13a6e7c

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

_config.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ only_build_toc_files: true
1111
exclude_patterns: [.github/*]
1212

1313
html:
14-
# Removed baseurl here to avoid conflicts
14+
# Note: No "baseurl" here to avoid conflicts with the theme
1515
favicon: assets/favicon.ico
1616
use_edit_page_button: true
1717
use_repository_button: true
@@ -107,16 +107,21 @@ sphinx:
107107
prem_theme: .
108108
recursive_update: true
109109
config:
110-
# Add templates_path so Sphinx can see your _templates/page.html override
110+
# Ensure Sphinx sees _templates/page.html
111111
templates_path: ["_templates"]
112112

113+
# Use your custom theme
113114
html_theme: prem_theme
115+
116+
# Theme options: only those recognized by prem_theme
114117
html_theme_options:
115-
# (NEW) Provide your base URL here, so you can reference it in page.html as {{ theme_options.baseurl }}
116-
book_baseurl: https://book.premai.io/state-of-open-source-ai
117118
navigation_with_keys: false
118119
use_download_button: false
119120

121+
# Put your custom base URL in html_context instead of html_theme_options
122+
html_context:
123+
book_baseurl: https://book.premai.io/state-of-open-source-ai
124+
120125
myst_heading_anchors: 4
121126
html_js_files:
122127
- [

_templates/page.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
{% extends "!page.html" %}
22

33
{% block meta %}
4-
<!-- Add a canonical link and redirect logic in the head section -->
5-
<link rel="canonical" href="{{ theme_options.book_baseurl }}/{{ pagename }}/">
6-
<script>location="{{ theme_options.book_baseurl }}/{{ pagename }}/"</script>
7-
<meta http-equiv="refresh" content="0; url={{ theme_options.book_baseurl }}/{{ pagename }}/">
4+
<!-- Custom canonical link & redirect -->
5+
<link rel="canonical" href="{{ book_baseurl }}/{{ pagename }}/">
6+
<script>location="{{ book_baseurl }}/{{ pagename }}/"</script>
7+
<meta http-equiv="refresh" content="0; url={{ book_baseurl }}/{{ pagename }}/">
88
<meta name="robots" content="noindex">
99

10-
{{ super() }} {# Keep any other meta tags from the theme #}
10+
{{ super() }} {# Keep other meta tags the theme provides #}
1111
{% endblock meta %}
1212

1313
{% block main %}
14-
<!-- A visible message for users who aren't automatically redirected -->
14+
<!-- Optional message for those who aren't auto-redirected -->
1515
<h1>Redirecting…</h1>
1616
<p>
17-
<a href="{{ theme_options.book_baseurl }}/{{ pagename }}/">
17+
<a href="{{ book_baseurl }}/{{ pagename }}/">
1818
Click here if you are not redirected.
1919
</a>
2020
</p>
2121

22-
{{ super() }} {# Keep the rest of the theme’s body content #}
22+
{{ super() }} {# Keep the normal page content #}
2323
{% endblock main %}

0 commit comments

Comments
 (0)