DM1: How search engines find and rank pages

Lesson 2 of 5 · reading 15–25 minutes; practice and project time is on the module page

Crawling: links, robots rules and status codes

🎯You'll be able to

Explain how crawlers discover pages, write a robots.txt that allows what should be crawled, and read HTTP status codes.

🏠The everyday picture

A postal worker finds houses by following roads and addresses. A "No entry" sign at the start of a lane keeps them out of every house on it, even the ones expecting letters.

📘What it really is

User-agent: *
Disallow: /checkout/
Sitemap: https://www.mittimart.example/sitemap.xml

📝A worked example

Input: MittiMart's starter robots.txt:

# STARTER: copied from the staging site (Project 3)
User-agent: *
Disallow: /product/

Steps:

  1. Read it: every product page is blocked, and there's no Sitemap line.
  2. Rewrite it: User-agent: *, Allow: /, and Sitemap: https://www.mittimart.example/sitemap.xml.
  3. Run npm run test:seo and read test 4.

Expected output: test 4 no longer reports "robots.txt must not block /product/" (it will still ask for noindex on the cart, checkout and thank-you pages until those are fixed).

🌍Where it's used

📝Case scenario

A travel site deleted 2,000 old tour pages and returned 404 for all of them. Many had links from blogs. The team redirected the 200 most-linked pages to the closest current tours with 301, and let the rest return 410. Visits from those links came back.

🖱️Try it

Open /robots.txt on three sites you use (for example a shop, a news site and a government portal). Note one path each one disallows and guess why. Success: three paths with a sensible reason for each.

⚠️Common mistakes

🛠️For your project

Project 3's tests 4 and 6 check robots.txt and broken links; the starter blocks /product/ and links to a removed lamp page.

✅Quick check

Does Disallow keep a page out of search results?

Show the answer

Not reliably. It stops crawling; a linked page can still be listed. Use noindex on a crawlable page.

Which status code tells a crawler a page has moved for good?

Show the answer

301.

← PreviousSearch as a channel
ProLearners Assist