HTML Course 15.3 Metadata for SEO: meta robots, canonical (conceptual)


15.3 Metadata for SEO: meta robots, canonical

Search engines rely on HTML metadata to decide which pages to crawl, index, and how to handle duplicate or near-duplicate content. Two of the most important tags are the <meta name='robots'> tag (for crawler directives) and the <link rel='canonical'> tag (for duplicate‐content control).

1. Meta Robots Tag

The <meta name='robots'> tag is placed within the <head> section and gives instructions to search engine crawlers (user-agents) about whether they may index a page and follow its links, among other behaviors.

Common Directives

Directive Description
index Allow the page to be indexed.
noindex Prevent the page from being indexed.
follow Allow search engines to follow links on the page.
nofollow Prevent search engines from following links.
noarchive Prevent display of cached copy in search results.
nosnippet Prevent generation of text snippets under the result.
noodp / noydir Ignore directory titles/descriptions from DMOZ/Yahoo Directory.
noimageindex Prevent images on the page from being indexed.
unavailable_after: date Make the page non-indexable after the specified GMT date.

Syntax & Examples

By default, if no meta robots tag is present, search engines assume index, follow. To override this, include a tag like:



  

To exclude a page from search results and prevent link following:



  

Combine multiple directives by comma‐separating them (order does not matter):



  

User-Agent-Specific Rules

You can target specific crawlers by replacing robots with the crawler name (e.g., googlebot, bingbot):



  

Multiple meta tags can coexist for different user-agents:




  

2. Canonical Link Tag

The <link rel='canonical'> tag tells search engines which URL is the preferred (“canonical”) version of a page when there are multiple URLs with identical or similar content. It helps consolidate ranking signals and avoids duplicate‐content penalties.

Best Practices

  • Always use an absolute URL in the href (including protocol, domain, path).
    Incorrect: <link rel='canonical' href='/products?id=123'>
    Correct: <link rel='canonical' href='https://www.example.com/products/123'>
  • Include the canonical tag on every variant page, including the canonical itself (self-referencing).
  • Ensure the canonical URL returns an HTTP 200 status (not a redirect or error).
  • Do not point multiple pages to one another in a loop or chain; always point to the final preferred URL.
  • When paginating, use rel='prev' and rel='next' alongside canonical, or use distinct self-referencing canonicals per page.

Examples

Basic self-referencing canonical:



  

Multiple URL variants pointing to a single canonical:



  

Handling query parameters:



  

3. Common Pitfalls & Troubleshooting

  • Missing or malformed URLs: A typo in href yields invalid canonical and crawlers may ignore it.
  • Redirecting canonical URLs: Pointing to a URL that itself redirects forces crawlers to resolve the redirect chain, losing juice.
  • Conflicting signals: A noindex meta robots together with a self-referencing canonical is contradictory—crawlers may drop the page entirely.
  • Cross-domain canonicals: Valid but use with care; Google supports them only if you verify ownership in Search Console of both domains.

4. Combining meta robots & canonical

Often you’ll want to both designate a canonical and control indexation/follow behavior. A typical pattern for a page you want indexed and canonicalized:




  

If you wish to keep a page out of search results but still consolidate its signals onto a canonical page, avoid using canonical alone. Instead:




  

5. HTTP Header Alternative: X-Robots-Tag

For non-HTML resources (PDFs, images, videos) you can use the X-Robots-Tag HTTP header to apply the same directives:

HTTP/1.1 200 OK
Content-Type: application/pdf
X-Robots-Tag: noindex, noarchive
  

This is useful when you cannot insert HTML <meta> tags.

Conclusion

Properly configured <meta name='robots'> and <link rel='canonical'> tags are essential tools in your SEO toolbox. They let you control which pages get indexed, how link equity is passed, and prevent duplicate content issues that can dilute your site’s rankings.


Posted

in

by

Tags:

Comments

Leave a Reply