Home >Web >Technical SEO >How search engines crawl and index a website

How search engines crawl and index a website

Before a page appears in search results, a search engine robot has to find it, download it and add it to the index. What decides along the way: links, HTTP status codes, JavaScript – and where to find out how your website fared.

Three steps: crawling, rendering, indexing

  1. Crawling – the search engine robot (Googlebot, Bingbot, SeznamBot) downloads pages. It finds new addresses from links on pages it already knows, from the sitemap (see Sitemaps and multilingual sites) and from links from other websites. Before crawling, it reads the robots.txt file, see robots.txt, noindex and X-Robots-Tag.
  2. Rendering – Google puts downloaded HTML with the status code 200 into a queue and renders it in the current version of Chromium, including JavaScript. Rendering may happen within a few seconds or later.
  3. Indexing – the search engine analyzes the page (text, headings, links, images, structured data), picks one canonical address among similar addresses (see Canonical URLs and duplicate content) and stores it in the index.

Only pages from the index can appear in search results. A search engine does not index everything it downloads – it leaves out low-value, duplicate and error pages. And not every indexed page shows up in the results for the queries you would like: the ranking is decided by the content and many other signals that technical SEO does not control. Technical SEO only makes sure that the robot finds the pages, downloads them and understands them correctly.

Links the robot can find

The robot follows only real links – the a element with the href attribute. It does not find navigation built on clicks in JavaScript:

<!-- the robot finds this link -->
<a href="/menu/">Menu</a>
<!-- the robot does not find these links: href is missing or leads only to # -->
<span onclick="location.href='/menu/'">Menu</span>
<a href="#" onclick="openSection('menu')">Menu</a>

Google finds a link inserted by JavaScript if it has the form <a href="…"> and the script runs during rendering. Likewise, every page needs its own address: content that changes only after the # character (/#menu, /#contact) is treated by Google as one page. JavaScript applications should therefore use real paths through the History API (history.pushState).

HTTP status codes

Every server response starts with a status code. For the robot, it is the first and most important information about the page:

  • 200 OK – the page exists and the robot processes it.
  • 301 and 308 (permanent redirect) – the page has moved. For Google it is a strong signal that it should show the target address in the index. How to set up redirects is described in the article Redirects in .htaccess.
  • 302 and 307 (temporary redirect) – only a weak signal, the original address usually stays in the index. Googlebot follows a redirect chain for at most ten steps.
  • 304 Not Modified – the page has not changed since the last visit (a response to a conditional request, see Browser cache).
  • 404 Not Found and 410 Gone – the page does not exist. Google handles both codes the same way: it drops a previously indexed address from the index over time and visits it less and less. A 404 error page does not harm the website; it is the normal state for addresses that never existed or have ceased to exist.
  • 401 and 403 – for Google just other 4xx errors. You cannot influence the crawl rate with them.
  • 429 Too Many Requests and 500, 502, 503 – the server is overloaded or not working. Google temporarily slows down crawling. Addresses that return a server error for a long time are eventually dropped from the index.

A page that does not exist must return 404

A common mistake of dynamic websites: the address of an article that does not exist shows the text “Page not found”, but with the status code 200. The robot then treats such a page as an ordinary one and Google marks it in Search Console as a soft 404 – a page that looks like an error page but does not report an error. Empty listings end up the same way (categories without articles, empty search results). In PHP it is enough to set the code with the http_response_code() function before printing the error page:

<?php
// article.php?url=… – an article by its address from the database
$pdo = require __DIR__.'/db.php';
$query = $pdo->prepare('SELECT title, text FROM articles WHERE url = ? AND visible = 1');
$query->execute(array(isset($_GET['url']) && is_string($_GET['url']) ? $_GET['url'] : ''));
$article = $query->fetch(PDO::FETCH_ASSOC);
if(!$article)
  {
    http_response_code(404);
    require __DIR__.'/404.php';   // the error page of the site: heading, search, links to the main sections
    exit;
  }
echo '<h1>'.htmlspecialchars($article['title']).'</h1>'."\n".$article['text'];

You can check the code with the curl command, which prints only the status code of the response (-s = no progress, -o /dev/null = discard the body, -w = what to print):

curl -s -o /dev/null -w "%{http_code}\n" "https://www.example.com/article.php?url=does-not-exist"
404

The command works in Git Bash and in the Windows 10 and 11 command prompt (write NUL there instead of /dev/null). In PowerShell 5.1, curl is an alias for a different command (Invoke-WebRequest), so write the full name curl.exe there. All response headers are printed by curl -I address.

Website maintenance: 503 and Retry-After

When you take the website offline for a while (moving to a new version, repairing the database), return the status code 503 Service Unavailable instead of the content. The robot recognizes that the state is temporary and does not drop the pages from the index – unlike a “Maintenance in progress” page with the status code 200, which it would index instead of the content. The Retry-After header says after how many seconds it should try again:

<?php
// at the beginning of index.php: as long as the maintenance.txt file exists, the site shows only the maintenance page
if(is_file(__DIR__.'/maintenance.txt'))
  {
    http_response_code(503);
    header('Retry-After: 3600');
    echo '<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>Website maintenance</title></head>'
      .'<body><h1>Maintenance in progress</h1><p>The website will be back within an hour.</p></body></html>';
    exit;
  }

Keep maintenance short – hours, a day or two at most. When the server returns a 5xx error for a long time, Google eventually drops the pages from the index.

JavaScript and rendering

Google renders pages, so it usually sees content added by JavaScript. There are catches, though:

  • Rendering comes only after downloading, sometimes with a delay. Content that is in the HTML straight from the server is available right away.
  • Google does not have to render pages with an error status code (for example 404).
  • When the original HTML contains <meta name="robots" content="noindex">, Google may skip rendering – a script that removes noindex later does not help.
  • Not all robots run JavaScript. Services that create a link preview when sharing (see Structured data and link previews) and many other robots read only the HTML from the server. That is why Google still recommends rendering the main content on the server – which is exactly what an ordinary website in PHP does.

Where the robot has been: the server access log

What robots actually download from the website is shown most precisely by the server access log. Hosting providers usually offer it for download in the control panel. Apache writes it in the combined format: IP address, time, request, status code, size, where the visitor came from and the browser identification (User-Agent). A sample log:

66.249.66.1 - - [09/Oct/2026:08:15:02 +0200] "GET /menu/ HTTP/1.1" 200 5120 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
66.249.66.1 - - [09/Oct/2026:08:15:09 +0200] "GET /events/summer-concert/ HTTP/1.1" 404 1830 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
198.51.100.23 - - [09/Oct/2026:08:16:40 +0200] "GET / HTTP/1.1" 200 7340 "https://www.google.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36"
40.77.167.5 - - [09/Oct/2026:08:20:11 +0200] "GET /menu/ HTTP/1.1" 200 5120 "-" "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)"
66.249.66.3 - - [09/Oct/2026:09:02:47 +0200] "GET /contact/ HTTP/1.1" 301 0 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
66.249.66.3 - - [09/Oct/2026:09:02:48 +0200] "GET /about-us/contact/ HTTP/1.1" 200 4410 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"

A script counts the status codes per robot and prints the addresses that ended with an error:

<?php
// robots-in-log.php – status codes received by search engine robots (Apache log in the combined format)
$robots = array('Googlebot', 'bingbot', 'SeznamBot');
$pattern = '~^(\S+) \S+ \S+ \[[^\]]+\] "\S+ (\S+) [^"]*" (\d{3}) \S+ "[^"]*" "([^"]*)"~';
$counts = array();
$errors = array();
foreach(file(__DIR__.'/access.log', FILE_IGNORE_NEW_LINES) as $line)
  {
    if(!preg_match($pattern, $line, $m)) continue;
    foreach($robots as $robot)
      {
        if(stripos($m[4], $robot) === false) continue;
        $counts[$robot][$m[3]] = (isset($counts[$robot][$m[3]]) ? $counts[$robot][$m[3]] : 0) + 1;
        if($m[3] >= 400) $errors[] = $m[3].' '.$m[2].' ('.$robot.', '.$m[1].')';
      }
  }
foreach($counts as $robot => $codes)
  {
    ksort($codes);
    $text = array();
    foreach($codes as $code => $count) $text[] = $code.': '.$count.'×';
    echo $robot.' – '.implode(', ', $text)."\n";
  }
echo "Errors:\n".implode("\n", $errors)."\n";
Googlebot – 200: 2×, 301: 1×, 404: 1×
bingbot – 200: 1×
Errors:
404 /events/summer-concert/ (Googlebot, 66.249.66.1)

Anyone can set their browser identification to “Googlebot”, though. Whether a request was really sent by Google is verified by the IP address. Google describes two steps in its documentation (Verifying Googlebot): the reverse DNS record of the IP address must end with the domain googlebot.com, google.com or googleusercontent.com and a lookup of the name found this way must return the same IP address. In PHP:

<?php
function is_google($ip)
  {
    $name = gethostbyaddr($ip);                     // reverse DNS: IP address → name
    if($name === false || $name === $ip) return false;
    if(!preg_match('~\.(googlebot|google|googleusercontent)\.com$~', $name)) return false;
    $addresses = gethostbynamel($name);             // forward check: name → IP addresses
    return $addresses !== false && in_array($ip, $addresses, true);
  }
var_dump(is_google('66.249.66.1'), is_google('8.8.8.8'));
bool(true)
bool(false)

The gethostbynamel() function returns only IPv4 addresses. DNS lookups take time, so store the result for each IP address and do not verify it on every request. Google also publishes lists of its IP address ranges in JSON format (common-crawlers.json and others), which allow verification without DNS. Bing and Seznam describe a similar verification.

Search engine tools

How a search engine sees your website is shown by its webmaster tools. All of them are free, and before using them you have to verify that you manage the website – most often with a TXT record in the DNS of the domain, a file uploaded to the website or a meta tag on the home page:

  • Google Search Console (search.google.com/search-console) – the page indexing report with the reasons why some addresses are not in the index (404, soft 404, redirect, duplicate, noindex, blocked in robots.txt), inspection of a specific address including the rendered HTML, sitemap submission, the robots.txt report, Core Web Vitals and search queries.
  • Bing Webmaster Tools (bing.com/webmasters) – the same for Bing. Sites can be imported directly from Search Console without further verification.
  • Seznam Webmaster (reporter.seznam.cz) – for Seznam, the Czech search engine that is still widely used in the Czech Republic.

The query site:example.com in a search engine shows only a rough and incomplete sample of the indexed pages. The exact numbers and reasons are only in the webmaster tools.

Related articles:
Redirects in .htaccess: 301, 302 and one address for the site
Error pages, file types and encoding
robots.txt, noindex and X-Robots-Tag
How to measure website speed: Core Web Vitals