learning-website-framework1-10 Exercise 2: Check the Build Against the Content ========================================================================== During a migration, the question "did every page survive?" must be answered by a script. Compare the set of pages the content tree says should exist with the set of pages that were actually built, in both directions. Needs sitemaps.py (Chapter 7). Save as parity.py: import os, sys from sitemaps import collect def built_pages(dist): out = set() for dirpath, dirnames, filenames in os.walk(dist): if "index.html" in filenames: rel = os.path.relpath(dirpath, dist).replace(os.sep, "/") out.add("/" if rel == "." else "/" + rel + "/") return out if __name__ == "__main__": content, dist = sys.argv[1], sys.argv[2] expected = set(collect(content)) built = built_pages(dist) missing = sorted(expected - built) extra = sorted(built - expected) print(f"expected from content/: {len(expected)} built in dist/: {len(built)}") print(f"expected but NOT built: {len(missing)}") for u in missing[:6]: print(" " + u) print(f"built but not expected: {len(extra)}") tops = {} for u in extra: tops.setdefault(u.strip("/").split("/")[0] or "(root)", []).append(u) for k, v in sorted(tops.items(), key=lambda kv: -len(kv[1]))[:8]: print(f" {k:<24}{len(v):>5} e.g. {v[0]}") Run it against the current site's build (astro-site/dist): python parity.py "/claude-projects/website-content/content" "/astro-site/dist" Output (checked by running it): expected from content/: 4925 built in dist/: 5014 expected but NOT built: 0 built but not expected: 89 sidebar 43 e.g. /sidebar/ai/cheat_sheet_claude_code_commands_print/ resources 20 e.g. /resources/csset/project_files/Exercises/Ch1/01_04/starter files/ programming 14 e.g. /programming/general-purpose-languages/python/python-lessons/python_lesson_boolean_logic_truthy_falsy_print/ japan 5 e.g. /japan/japanese-language/japanese-lessons/japanese_lesson_checking_into_the_hotel_print/ hungary 2 e.g. /hungary/hungarian-lessons/hungarian_lesson_possessive_suffixes_1st_2nd_person_print/ (root) 1 e.g. / admin 1 e.g. /admin/ ai 1 e.g. /ai/claude-tools/claude-lessons/ What it shows ------------- - Expected but not built: 0. Every page the content tree defines was built. - Built but not expected: 89. These are pages the live site publishes that the content walk in Chapter 7 deliberately skips: mainly the print variants of cheat sheets and lessons (names ending in _print), a number of resource folders, the home page, the admin dashboard and the course index. - So the print variants are real, public pages. Decide what you want for them: keep them, give each a canonical link to the main page, or ask search engines not to index them (Learning Website: Framework & Architecture 7). Use the same script during the migration: expected = the area's pages from the content tree; built = the new site's output folder. The result you want is 0 missing, and an extra list you can explain page by page. WHY THIS WORKS AS AN ANSWER --------------------------- A two-way comparison catches both losses (missing pages) and surprises (pages nobody planned). Running it on today's build first proves the method on a site you already trust, and it turned up the print pages as a decision still to make.