{{ message }}
Repository navigation
Conversation
GitHub Pages has no fallback for single-page apps, so with routerMode 'history' every lesson URL returned GitHub's 404 page when it was opened directly, reloaded or shared. The default hash router keeps every request on index.html, which GitHub Pages serves with HTTP 200. Lessons embed raw HTML such as <img src="images/..."> and translated pages link with <a href="../...">. Docsify does not rewrite raw HTML, and with the hash router the document URL is the site root, so an afterEach hook resolves those paths against the current markdown file, the same way Docsify resolves markdown images and links. Links to sections of the home page from the old router (/?id=...) are redirected to their hash route so they keep working.
05-Frameworks#overfitting resolves to a non-existent 05-Frameworks.md on the docs site. Point it at the lesson README instead.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Problem
The docs site uses Docsify with
routerMode: 'history', but GitHub Pages has no fallback for single-page apps. Navigating inside the site works. Opening, reloading or sharing a lesson URL does not: GitHub's 404 page comes back instead.Example: https://microsoft.github.io/AI-For-Beginners/lessons/3-NeuralNetworks/03-Perceptron/README
Fix
Switch to Docsify's default hash router. Lesson URLs become
/AI-For-Beginners/#/lessons/.... Every request then hitsindex.html, which GitHub Pages serves with HTTP 200.Switching the router alone would break about 1,800 images. 35 raw HTML
<img src="images/...">tags in the English lessons and about 1,780 intranslations/are written relative to their markdown file. The translated pages also contain about 80 raw<a href="../...">links. Docsify doesn't rewrite raw HTML. With the hash router the document URL is the site root, so those paths would resolve against the wrong folder. A smallafterEachplugin resolves them against the current markdown file instead, the same way Docsify already handles markdown images and links. It runs before the HTML is inserted into the page, so wrong URLs are never requested.Home-page section links from the old router (
/?id=section) are redirected to#/?id=section, so links already shared keep working.Why not a
404.htmlfallback?A copy of
index.htmlas404.htmlwould keep history URLs and the relative raw HTML paths working. But:Hash routing works on any static host, with no error responses and no second file.
Trade-offs
#/. Lesson URLs in the old history format never loaded directly, so no working link breaks./AI-For-Beginners/lessons/.../README) keep returning 404, as they do today.Also in this PR
lessons/3-NeuralNetworks/README.mdlinked to05-Frameworks#overfitting, which resolves to a non-existent05-Frameworks.mdon the site. The link now points to05-Frameworks/README.md#overfitting.Verification
Tested with a local static server that behaves like GitHub Pages (case-sensitive paths, tries
path,path.htmlandpath/index.html, otherwise 404, served under/AI-For-Beginners/). The baseline reproduced the live 404. Tested twice: with this branch as it is (Docsify 4.13.1), and merged with #768 (Docsify 5.0.0), which merges without conflicts.#/lessons/3-NeuralNetworks/03-Perceptron/READMErender the lesson, and its raw HTML images load.05-Frameworks/README?id=overfittingand scrolls to the heading.?id=URLs scrolls to the heading, for lesson pages and the home page. Legacy/?id=quizzesis rewritten to#/?id=quizzes.<a href="../lessons/2-Symbolic/README.md">intranslations/README.ja.mdopens the right page.Notes
.ipynbfiles show Docsify's "404 - Not found" page when clicked, both on the live site and with this change. Not addressed here.🤝-contributingbecomes-contributing. Old?id=links to those headings won't scroll under v5, whichever router is used.