Sub topic 1
How Google Search Works: Crawl, Index, Serve
Prerequisites
This chapter assumes you know how to use a web search engine and understand what a web page and a URL are. Reading simple HTML helps for the code samples, but you can follow the main ideas without it.
The three stages
Google Search turns a query into an ordered list of results in three stages: crawling, indexing, and serving. Each stage depends on the one before it. A page that is not crawled cannot be indexed, and a page that is not indexed cannot appear in results.
Stage 1: Crawling
Crawling is the process of fetching pages from the web. Google uses a program called Googlebot. It finds URLs by following links from pages it already knows and by reading sitemaps that site owners submit. It then requests each URL, much as a browser does.
Googlebot decides which sites to visit, how often, and how many pages to fetch. It slows down if your server responds slowly or returns errors. Some pages cannot be crawled at all, for example pages behind a login or pages blocked by robots.txt.
A robots.txt file tells crawlers which paths they may fetch. It can also point to your sitemap:
User-agent: *
Disallow: /cart/
Sitemap: https://www.example.com/sitemap.xmlStage 2: Indexing
Indexing is the process of analyzing a crawled page and storing what Google learned about it. Google reads the text, the title, images, video, and key tags. It also works out which URL is the preferred version when several URLs show the same content.
You can give Google hints in the head of your page. A descriptive title, a meta description, and a canonical link say what the page is about and which URL you prefer:
<head>
<title>How to Repot a Snake Plant | Example Garden</title>
<meta name="description" content="Step-by-step instructions for repotting a snake plant, including soil, pot size, and timing.">
<link rel="canonical" href="https://www.example.com/repot-snake-plant">
</head>Google does not index every page it crawls. A page may be left out because it has low-quality content, because a noindex rule excludes it, or because the site's design makes indexing hard.
Stage 3: Serving results
Serving happens when someone types a query. Google searches its index for candidate pages, then ranks them. Ranking uses many signals, including how well a page matches the query, its quality, and the searcher's context such as location and language. The rest of this tutorial covers these signals one by one.
The results page is built for each query. Depending on the query, it can include plain links, images, maps, or other features.
Common errors
The most frequent mistakes come from mixing up the stages.
- Blocking a page in
robots.txtto keep it out of results.robots.txtcontrols crawling, not indexing. Google can still index a blocked URL if other pages link to it, though it will not know the content. - Using
noindexon a page that is also blocked. Google must crawl the page to see thenoindextag. Ifrobots.txtblocks the crawl, the tag is never read. - Assuming a crawled page is indexed. Crawling does not guarantee indexing.
- Assuming an indexed page will rank. Being in the index only makes a page a candidate.
The noindex tag looks like this:
<meta name="robots" content="noindex">Summary of responsibilities
| Stage | What Google does | What you control |
|---|---|---|
| Crawl | Fetches pages by following links and sitemaps | Internal links, sitemap, `robots.txt`, server speed |
| Index | Analyzes and stores page content | Titles, canonical links, `noindex`, content quality |
| Serve | Matches and ranks pages for a query | Relevance and usefulness of the content |
Exercise
You add Disallow: /old-offers/ to robots.txt and also add a noindex meta tag to the pages in that folder. Weeks later the URLs still appear in search results. Why, and how would you fix it?
Show answer
Because robots.txt blocks crawling, Googlebot never fetches the pages and never sees the noindex tag. Remove the Disallow rule so Google can crawl the pages, keep the noindex tag, and wait for Google to recrawl them. If the content must stay private, put it behind authentication instead.
Exercise
Name the three stages of Google Search in order, and say which stage a canonical link mainly affects.
Show answer
Crawling, indexing, serving. A canonical link mainly affects indexing, because it tells Google which URL is the preferred version of a page.