Bot pages: use root-relative links so they work on any host

The generated /links-for-bots/ pages linked to absolute https://msosorg.com/...
URLs, which 404 when the site is served from another host (e.g. local dev, or
before this branch is deployed). Switch the pages' navigation links to
root-relative (/llms.txt, /en/..., /links-for-bots/...). Canonical tags stay
absolute (SEO) and llms.txt keeps absolute URLs (llmstxt.org convention).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
popovskikandClaude Opus 4.8 committed 2026-08-05 18:18:32 +02:00
1 parent ac052c2b09
commit e12724bbd1
6 files changed
+185 -182

No files matched your search

+18 -15
View File
@@ -48,8 +48,10 @@ def read_meta(path):
def page_url(path):
"""Root-relative URL (e.g. /en/blog/) so links work on any host — the local
dev server and production alike."""
rel = os.path.relpath(path, ROOT).replace("\\", "/")
return BASE + "/" + (rel[:-len("index.html")] if rel.endswith("index.html") else rel)
return "/" + (rel[:-len("index.html")] if rel.endswith("index.html") else rel)
def collect(lang):
@@ -109,7 +111,7 @@ def html_shell(title, desc, canonical, body):
<style>{PAGE_CSS}</style>
</head>
<body>
<nav class="crumbs"><a href="{BASE}/links-for-bots/">For bots</a> &rsaquo; {esc(title)}</nav>
<nav class="crumbs"><a href="/links-for-bots/">For bots</a> &rsaquo; {esc(title)}</nav>
{body}
</body>
</html>
@@ -153,18 +155,18 @@ def build_about():
space (the MSOS Hub), and practical help from application to graduation.</p>
<h2>What this site offers</h2>
<ul>
<li>A <a href="{BASE}/en/student-welcome-guide/">Student Welcome Guide</a> covering enrolment, residence, healthcare, accommodation, work and student life in Slovenia.</li>
<li>A <a href="{BASE}/en/blog/">blog</a> with practical articles and student stories.</li>
<li><a href="{BASE}/en/projects/">Events and projects</a>, a <a href="{BASE}/en/gallery/">gallery</a>, and <a href="{BASE}/en/news/">news</a>.</li>
<li>Ways to <a href="{BASE}/en/become-a-member/">become a member</a> or <a href="{BASE}/en/support/">support MSOS</a>.</li>
<li>A <a href="/en/student-welcome-guide/">Student Welcome Guide</a> covering enrolment, residence, healthcare, accommodation, work and student life in Slovenia.</li>
<li>A <a href="/en/blog/">blog</a> with practical articles and student stories.</li>
<li><a href="/en/projects/">Events and projects</a>, a <a href="/en/gallery/">gallery</a>, and <a href="/en/news/">news</a>.</li>
<li>Ways to <a href="/en/become-a-member/">become a member</a> or <a href="/en/support/">support MSOS</a>.</li>
</ul>
<p>Content is written by students for general guidance and may not always be current; official sources should be verified.
The site is trilingual — English (/en/), Macedonian (/mk/) and Slovenian (/si/).</p>
<h2>Machine-readable resources</h2>
<ul>
<li><a href="{BASE}/llms.txt">/llms.txt</a> — structured index of key pages</li>
<li><a href="{BASE}/sitemap.xml">/sitemap.xml</a> — full sitemap</li>
<li><a href="{BASE}/links-for-bots/">/links-for-bots/</a> — complete link lists</li>
<li><a href="/llms.txt">/llms.txt</a> — structured index of key pages</li>
<li><a href="/sitemap.xml">/sitemap.xml</a> — full sitemap</li>
<li><a href="/links-for-bots/">/links-for-bots/</a> — complete link lists</li>
</ul>
<p>Contact: <a href="mailto:info@msosorg.com">info@msosorg.com</a></p>"""
write("links-for-bots/about-msos/index.html",
@@ -176,12 +178,12 @@ def build_about():
def build_hub():
body = f""" <h1>Links for bots</h1>
<p class="intro">Plain, fully-linked indexes of msosorg.com for search engines and AI crawlers.
See also <a href="{BASE}/llms.txt">/llms.txt</a> and <a href="{BASE}/sitemap.xml">/sitemap.xml</a>.</p>
See also <a href="/llms.txt">/llms.txt</a> and <a href="/sitemap.xml">/sitemap.xml</a>.</p>
<ul>
<li><a href="{BASE}/links-for-bots/blog/">Blog article links</a></li>
<li><a href="{BASE}/links-for-bots/guide/">Student guide links</a></li>
<li><a href="{BASE}/links-for-bots/projects/">Events &amp; projects links</a></li>
<li><a href="{BASE}/links-for-bots/about-msos/">Hey AI, learn about us</a></li>
<li><a href="/links-for-bots/blog/">Blog article links</a></li>
<li><a href="/links-for-bots/guide/">Student guide links</a></li>
<li><a href="/links-for-bots/projects/">Events &amp; projects links</a></li>
<li><a href="/links-for-bots/about-msos/">Hey AI, learn about us</a></li>
</ul>"""
write("links-for-bots/index.html",
html_shell("Links for bots", "Crawl hub for msosorg.com (blog, guide, projects) plus an AI summary.",
@@ -203,7 +205,8 @@ def build_llms_txt():
continue
lines.append(f"## {label}")
for title, url, desc in rows:
lines.append(f"- [{title}]({url}): {desc}" if desc else f"- [{title}]({url})")
abs_url = BASE + url # llms.txt convention: absolute URLs
lines.append(f"- [{title}]({abs_url}): {desc}" if desc else f"- [{title}]({abs_url})")
lines.append("")
io.open(os.path.join(ROOT, "llms.txt"), "w", encoding="utf-8", newline="\n").write(
"\n".join(lines).rstrip() + "\n")