How to remove a webpage from the Google index
Tags: it, web, html
Published: 2019-07-18 20:42:56

---
title: How to remove a webpage from the Google index
published: true
tags: it, web, html
canonical_url: https://vorakl.com/articles/remove-webpage-google/
---

It's important to keep in mind that search engines scan websites on periodic bases and these periods may vary depending on a number of factors. In general, websites' owners don't have full control over the behavior of search engines, but instead, they can define preferences in a form of instructions. Such instructions, for example, allow excluding certain web pages from showing up in search results or preventing search engines from digging into specific paths. There are two ways to declare preferences: tweaking parameters of [robots.txt](https://www.robotstxt.org/) in the root of a website and [HTML `<meta>` tag "robots"](https://developers.google.com/search/reference/robots_meta_tag) in the `<head>` block of web pages.

  

I've recently needed to move one of my static websites to another domain. It became a complex task as I'm not able to change a server-side configuration, and the [redirection of HTTP-requests](https://vorakl.com/articles/canonical/) is only one part of the story. Once all users are being redirected to a new location, I had to initiate and speed up a process of cleaning up the search results from links to my old website.

  

There are basically a few common ways to remove web pages from search indexes:

- remove a page completely, so clients will be getting [404 Not Found](https://tools.ietf.org/html/rfc2616#section-10.4.5) HTTP response. It is clearly not my case, as the old website responses with valid and existing web pages
- restrict access to a page by asking clients to enter credentials. Then, the server will be sending [401 Unauthorized](https://tools.ietf.org/html/rfc2616#section-10.4.2) HTTP response. This also won't work for me, as requires changing the configuration on the server-side
- add an HTML `<meta>` tag _robots_ with the value [noindex](https://support.google.com/webmasters/answer/93710). That's exactly what I needed and can be implemented on the client-side.

The last method allows setting different preferences per page right from the HTML code. That is, search engines must have access to a page to read it and find this instruction. This also means that all web pages with _robots_ meta tag shouldn't be blocked even by a robots.txt file!

  

This solution will show a few steps for removing an entire website from Google's search results.

- check _robots.txt_ (if it exists) and be sure that search bots are allowed to go through the site and read all indexed web pages. The file should either be empty or something like this (allows any bots read any webpage on a site):

```
User-agent: * 
Disallow:
```

- add _robots_ HTML `<meta>` tag in the `<head>` block with "noindex, nofollow" value in each indexed web page:

```
<meta name="robots" content="noindex, nofollow" />
```

- create a [sitemap.xml](https://www.sitemaps.org/) file and define all indexed web pages with the `<lastmod>` section which points to some recent time. For example:

```
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    <url>
        <loc>https://example.com/page1/</loc>
        <changefreq>daily</changefreq>
        <lastmod>2019-06-15</lastmod>
    </url>
    <url>
        <loc>https://example.com/page2/</loc>
        <changefreq>daily</changefreq>
        <lastmod>2019-06-15</lastmod>
    </url>
</urlset>
```

- [submit this sitemap.xml file](https://www.sitemaps.org/protocol.html#submit_ping) to Google to let it know about recent changes. It can be done using _curl_ command:

```
curl -sSLf https://google.com/ping?sitemap=https%3A%2F%2Fexample.com%2Fsitemap.xml
```

- [submit a removal request](https://www.google.com/webmasters/tools/removals) for each indexed web page. It may take several days for some links (and a few tries per a page's URL) to get considered "outdated" and eligible for deleting from the index