Skip to content

Enable the language switcher and fix this edition's site URLs - #145

Merged
mmcky merged 2 commits into
mainfrom
add-language-switcher
Aug 3, 2026
Merged

Enable the language switcher and fix this edition's site URLs#145
mmcky merged 2 commits into
mainfrom
add-language-switcher

Conversation

@mmcky

@mmcky mmcky commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Two related changes: enable the language switcher, and point this edition's URLs at the address it is actually served from. The second is a prerequisite for the first to be worth anything, which is why they are together — see below.

1. Language switcher

Adds the switcher configuration to html_theme_options, mirroring QuantEcon/lecture-python-programming#490 which adds the same block to the English source.

Code Name URL
en English https://python-programming.quantecon.org
fa فارسی https://quantecon.github.io/lecture-python-programming.fa
fr Français https://quantecon.github.io/lecture-python-programming.fr
zh-cn 中文 https://quantecon.github.io/lecture-python-programming.zh-cn

current_language: fa, so this edition renders as active. English stays first because the theme uses languages[0] as the hreflang x-default target.

This does not propagate from the English source: the sync workflows trigger only on lectures/**/*.md and lectures/_toc.yml, so _config.yml never reaches a sync run, and each edition needs its own current_language anyway.

2. Site URLs

html.baseurl was https://python-programming-fa.quantecon.org/, and that host does not resolve — DNS fails. Every page emitted a canonical and an og:url pointing at a dead address, while the site actually serves from https://quantecon.github.io/lecture-python-programming.fa/. Both tojupyter_urlpath and tojupyter_image_urlpath carried the same dead host, so generated notebooks resolved their links and images there too.

This edition is hosted at its GitHub Pages URL while the broader URL structure is worked out, so all three now say that.

This matters for part 1 rather than being incidental to it. Search engines reconcile hreflang against each page's canonical; with the canonical pointing somewhere unreachable, the annotations could not form a valid cluster and the SEO half of the switcher would have been inert.

Also drops nb_repository_url, which pointed at lecture-python-programming.fa.notebooks — a repository that does not exist. Replaced with the same explanatory comment the fr edition already carries; the theme omits notebook-launch links when the option is unset, which is how .fr runs in production today.

Verification

Built locally against quantecon-book-theme==0.21.0, which this repo already pins:

  • The switcher lists all four languages with فارسی active.
  • dir="rtl" is preserved on <body>enable_rtl: True is untouched.
  • hreflang alternates inject, including x-default → en.
  • canonical and og:url now read https://quantecon.github.io/lecture-python-programming.fa/{page}.html, matching this edition's own hreflang self-reference. That agreement is what makes the cluster coherent.

Note

Nothing here changes a live page until a publish* tag is pushed. This edition last published on 2026-06-19.

Mirrors QuantEcon/lecture-python-programming#490, which adds the same
block to the English source. Lists all four editions with
current_language set to fa so this edition renders as active, and
injects the hreflang alternates for the set.

English stays first in the list because the theme uses languages[0] as
the hreflang x-default target.

Verified with a local build against the theme: the switcher lists all
four languages with fa active.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings August 3, 2026 01:12
@netlify

netlify Bot commented Aug 3, 2026

Copy link
Copy Markdown

Deploy Preview for majestic-griffin-10b166 ready!

Name Link
🔨 Latest commit 42577c5
🔍 Latest deploy log https://app.netlify.com/projects/majestic-griffin-10b166/deploys/6a6fed82fd735e00085bf91e
😎 Deploy Preview https://deploy-preview-145--majestic-griffin-10b166.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Ready to approve

The change is a small, self-contained theme configuration update that mirrors the known upstream pattern and does not alter any runtime code paths.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Pull request overview

This PR enables the QuantEcon Book Theme language switcher for the Farsi (fa) edition by adding the theme’s languages configuration and setting current_language: fa in the Jupyter Book/Sphinx config.

Changes:

  • Add html_theme_options.languages entries for en/fa/fr/zh-cn with their public URLs.
  • Set html_theme_options.current_language: fa so the switcher correctly marks فارسی as active.
File summaries
File Description
lectures/_config.yml Adds the language-switcher configuration block and sets the current language to Farsi for this edition.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

@github-actions
github-actions Bot temporarily deployed to pull request August 3, 2026 01:17 Inactive
baseurl claimed https://python-programming-fa.quantecon.org/, a host
that does not resolve, so every page emitted a canonical and og:url to
a dead address while the site serves from github.io. The two
tojupyter paths carried the same dead host.

This edition is hosted at its GitHub Pages URL while the broader URL
structure is decided, so the config now says so.

Also drops nb_repository_url, which pointed at
lecture-python-programming.fa.notebooks — a repository that does not
exist. Mirrors the comment the fr edition already uses; the theme
skips notebook-launch links when the option is unset.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@mmcky mmcky changed the title Enable the language switcher for the Farsi edition Enable the language switcher and fix this edition's site URLs Aug 3, 2026
@github-actions
github-actions Bot temporarily deployed to pull request August 3, 2026 01:28 Inactive
@mmcky
mmcky merged commit 2c974ed into main Aug 3, 2026
7 checks passed
@mmcky
mmcky deleted the add-language-switcher branch August 3, 2026 01:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants