learning-website-framework1-10 Exercise 3: The Exceptions List and a Cutover Plan ============================================================================== PART A: List what does not move by the folder rule --------------------------------------------------- Most pages move because their folder is assigned to a site. Some things are not content folders: shared resource folders and special routes. Inventory them and decide where each goes. Save as exceptions.py: import os, sys BELONGS = {"japanese": "languages", "hungarian": "languages"} # resources/ -> site def folder_stats(path): files = size = 0 for dp, dn, fn in os.walk(path): for f in fn: files += 1 size += os.path.getsize(os.path.join(dp, f)) return files, size if __name__ == "__main__": public = sys.argv[1] res = os.path.join(public, "resources") print(f"{'/resources/...':<22}{'files':>7}{'size':>10} moves with") for name in sorted(os.listdir(res)): p = os.path.join(res, name) if os.path.isdir(p): n, b = folder_stats(p) print(f"{name:<22}{n:>7}{b/1e6:>8.1f} MB {BELONGS.get(name, '(decide: not a language asset)')}") print() print("special routes that are not files in content/:") print(" /japan/kanji-tiles/ -> languages (page built from kanji_tiles_cms_content.html)") print(" /japan/hiragana/hiragana-tiles -> linked by 141 pages, route does NOT exist") print(" /japan/katakana/katakana-tiles -> linked by 141 pages, route does NOT exist") Run it: python exceptions.py "/astro-site/public" Output (checked by running it): /resources/... files size moves with csset 149 10.7 MB (decide: not a language asset) hungarian 11 104.8 MB languages japanese 312 1.6 MB languages jquery 25 0.0 MB (decide: not a language asset) js 30 0.0 MB (decide: not a language asset) js2021 66 0.6 MB (decide: not a language asset) linux 6 5.2 MB (decide: not a language asset) php 112 0.7 MB (decide: not a language asset) postman 2 0.0 MB (decide: not a language asset) special routes that are not files in content/: /japan/kanji-tiles/ -> languages (page built from kanji_tiles_cms_content.html) /japan/hiragana/hiragana-tiles -> linked by 141 pages, route does NOT exist /japan/katakana/katakana-tiles -> linked by 141 pages, route does NOT exist Decisions for the languages move -------------------------------- - resources/japanese (312 files, 1.6 MB): move with the area. The hiragana and katakana reference pages and the live kanji pages are served from here. - resources/hungarian (11 files, 104.8 MB): move with the area, but look at it first. It holds PDFs, a video and screenshots whose names look like a published Hungarian textbook and a lesson recording. Check that you have the right to publish them (see Copyright & Fair Use), and think about whether 100 MB of video should live in the web root at all. - The other resource folders (csset, jquery, js, js2021, linux, php, postman) are not language assets. They stay on the old site until their own areas move. - /japan/kanji-tiles/ moves with the area (it is built from a file in the japan folder). - The dead hiragana and katakana tiles links: fix them first (build the two missing tile pages from the existing *_tiles_cms_content.html files, or change the back-links to point at a page that exists). PART B: A cutover plan you can follow ------------------------------------- Phase 0 Prepare Fix the dead tile links on the CURRENT site. Run the secrets scan (Chapter 8). Decide the print-page policy and the resources/hungarian question. Phase 1 Build in parallel Create DNS, virtual host and certificate for languages.osztromok.com (Chapter 8). The new site's robots.txt BLOCKS crawling so that the same pages are not indexed in two places. Deploy the first release. Phase 2 Verify (the old site is untouched) - parity.py: 0 missing pages - link inventory on the new build: 0 broken links - resource files open (PDF, kanji pages, reference pages) - menus, canonical links and the sitemap use the new addresses - look at a sample of each page type by eye Phase 3 Rehearse the redirects Turn on the redirect rule with 302 (temporary) on the old site and test every old URL. Rollback: remove the rule. Nothing is lost. Phase 4 Switch Allow crawling on the new site, submit its sitemap, change the redirects to 301, and replace the languages menu entry on the old site with a link to the new site. Phase 5 Watch For a few weeks: server logs for 404s from old URLs, Search Console coverage and crawl errors, and any visitor reports. Phase 6 Retire Only when the new site is stable, remove the language folders from the old site's build. Keep the redirects for at least a year. The content stays in the content folder: it is the source for the new site. At every phase there is a way back: until Phase 6 the old copy still exists. WHY THIS WORKS AS AN ANSWER --------------------------- The plan is small and testable at each step, and the exception list is built from the real folders, so surprises (the 105 MB folder, the dead links) show up before cutover instead of during it.