| Duration | ~55 min in the lesson + ~30 min homework |
| Prerequisites | Checkpoint lesson-3.8. |
| Checkpoint | lesson-3.9 |
What you will have
You have measured the live site with Lighthouse, had Claude fix the top issues and measured again, with both reports saved in docs/lighthouse/. The site has a sitemap and a robots file on the live domain, and structured data describing the business.
Video
The video for this lesson is not recorded yet.
Prompts used in this lesson
Part 4 — Measure, fix, measure again
Purpose: record a baseline of the live site's speed before changing anything. Context: the live site is https://[your-domain]. Done when: - docs/lighthouse/ contains before.report.html and before.report.json for the home page, produced by: npx lighthouse https://[your-domain] --output html --output json --output-path docs/lighthouse/before --chrome-flags="--headless=new" - you ran it three times and kept the run with the middle performance score; - you give me a table from the JSON: the performance, accessibility, best practices and SEO scores; LCP, CLS and Total Blocking Time; which element is the LCP element; and the top five opportunities, each explained in one plain sentence. Constraints: measure only; change no code. Default (mobile) settings.
Purpose: fix the biggest speed problems in the baseline without changing how the site looks or behaves. Context: baseline in docs/lighthouse/before.report.json. Read the image and font guides in node_modules/next/dist/docs first. Done when the top opportunities are fixed, and you have checked and reported on each of these: 1. the hero image is requested at a size suited to the viewport and is the only eagerly loaded image; other images lazy-load; source files are no larger than needed; 2. only the font families and weights the design uses are loaded; 3. no unused libraries or imports remain, icons are imported individually, and only components that need interactivity run in the browser. Constraints: no visual changes, no new libraries, no removed features. Do not chase 100: stop when LCP, CLS and Total Blocking Time are in Lighthouse's good range, and tell me what you left and why. Before reporting: build and lint; compare screenshots at 375px, 768px and 1280px with the live site; list each change and the baseline item it addresses. Then commit and push.
Purpose: measure the result of the speed fixes. Context: the fixes are deployed. Baseline: docs/lighthouse/before.report.* Done when: docs/lighthouse/after.report.html and after.report.json exist, produced the same way (three runs, middle one kept), and docs/lighthouse/summary.md has a before/after table of the four category scores, LCP, CLS and Total Blocking Time, with the date, the URL, and one line on what remains unfixed and why. Constraints: same command and settings. First confirm that the latest commit is the one deployed.
Part 5 — Search basics
Purpose: make the site easy for search engines to read. Context: siteUrl is in content/site.ts. Index: /, /privacy, /terms. Do not index: /thank-you, /styleguide. Later sections add /admin and /api, which crawlers should not crawl. Business facts are in content/site.ts and docs/brief.md. Read the sitemap, robots and JSON-LD pages in node_modules/next/dist/docs first. Done when: - app/sitemap.ts generates /sitemap.xml with only the three public pages, as absolute addresses built from siteUrl; - app/robots.ts generates /robots.txt that allows crawling in general, disallows /admin and /api, and points to the sitemap; - the home page includes JSON-LD of the fitting schema.org local-business type with only: name, description, url, telephone, email, address or area served, and opening hours if docs/brief.md states them; - every indexable page has a canonical address. Constraints: no ratings, reviews, prices or awards unless they are in docs/content.md and visible on the page. Escape the JSON as the Next.js guide describes. Before reporting: build; start the production server; show me the full contents of /sitemap.xml and /robots.txt and the JSON-LD as rendered in the home page's HTML; re-run Lighthouse and report the SEO score.
Do along
Work on your own project and pause the video where told.
- Start from
lesson-3.8, deployed. - Pause after Part 3. Run Lighthouse yourself in Chrome DevTools, in a private window, on your live domain. Find the category scores, LCP, CLS and Total Blocking Time.
- Pause after Part 4. Run the baseline prompt with your domain. Read the top five opportunities.
- Run the fix prompt. Check the page at three widths before accepting that nothing changed visually.
- After the deployment, run the "after" prompt and read
docs/lighthouse/summary.md. - Pause after Part 5. Run the search prompt. Read the sitemap, robots file and structured data in full; remove any fact that is not true.
- After Part 6, push. Open
/sitemap.xmland/robots.txton your live domain. - Save the checkpoint with the commands under "Recap and next".
Check your work
- Open
docs/lighthouse/. Expected:before.report.html,after.report.html, their JSON files andsummary.md; both HTML reports open in a browser. - Read
summary.md. Expected: in the "after" column LCP is 2.5 s or less and CLS 0.1 or less, with Total Blocking Time in Lighthouse's good range, or a written reason for anything that is not. - Open
https://your-domain/sitemap.xml. Expected: three addresses, all beginning with yourhttps://domain. - Open
https://your-domain/robots.txt. Expected: a general allow, disallow lines for/adminand/api, and a sitemap line. npm run buildandnpm run lint. Expected: both pass.
Common problems
- Scores differ between runs → normal variation → run three times, take the middle, and compare before and after under the same conditions.
- Lighthouse fails to start from the terminal → Chrome is missing, or Node is older than the tool requires → install Chrome and give Claude the exact error; as a fallback run it in DevTools and save the report from there.
- Sitemap lists
http://localhost:3000→siteUrlis wrong → correct it incontent/site.tsand redeploy.
Homework
About 30 minutes, after the lesson. No later lesson depends on it.
- Measure two more pages. Run Lighthouse in DevTools, in a private window, on your own
/privacypage and on the home page of a business like yours. Deliverable:docs/lighthouse/other-pages.mdwith the date and, for each page, the four category scores, LCP, CLS and Total Blocking Time, plus one sentence on the biggest difference from your home page. Commit without a tag. Done when: the file has both pages and you did not touch the before and after reports. - Phone on mobile data. With Wi-Fi off, open your domain in a private tab three times and count the seconds until the headline is readable. Deliverable: three timings in your notes, with date and place. Done when: you have three numbers and one line on whether the wait felt acceptable.
- Search baseline. Search for your business name, then for your service plus your city. Deliverable: in your notes: the date, whether your site appeared for each search, and the titles of the top three results. Done when: both searches are recorded. Whatever you see today is the baseline to compare against later.
Save your work
git add -A
git commit -m "Lesson 3.9: Lighthouse baseline and fixes, sitemap, robots, structured data"
git tag lesson-3.9
git push
git push --tags