AI Global Academy Join the waitlist

Courses / Frontend: the website

Lesson 3.9 · 55 minSpeed and search basics

Duration~55 min in the lesson + ~30 min homework
PrerequisitesCheckpoint lesson-3.8.
Checkpointlesson-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

Prompt to Claude
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.
Prompt to Claude
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.
Prompt to Claude
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

Prompt to Claude
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.

  1. Start from lesson-3.8, deployed.
  2. 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.
  3. Pause after Part 4. Run the baseline prompt with your domain. Read the top five opportunities.
  4. Run the fix prompt. Check the page at three widths before accepting that nothing changed visually.
  5. After the deployment, run the "after" prompt and read docs/lighthouse/summary.md.
  6. 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.
  7. After Part 6, push. Open /sitemap.xml and /robots.txt on your live domain.
  8. Save the checkpoint with the commands under "Recap and next".

Check your work

  1. Open docs/lighthouse/. Expected: before.report.html, after.report.html, their JSON files and summary.md; both HTML reports open in a browser.
  2. 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.
  3. Open https://your-domain/sitemap.xml. Expected: three addresses, all beginning with your https:// domain.
  4. Open https://your-domain/robots.txt. Expected: a general allow, disallow lines for /admin and /api, and a sitemap line.
  5. npm run build and npm 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 → siteUrl is wrong → correct it in content/site.ts and redeploy.

Homework

About 30 minutes, after the lesson. No later lesson depends on it.

  1. Measure two more pages. Run Lighthouse in DevTools, in a private window, on your own /privacy page and on the home page of a business like yours. Deliverable: docs/lighthouse/other-pages.md with 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.
  2. 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.
  3. 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