Metadata is simply, information about data. In HTML documents, the <meta>
element provides information to browsers about the HTML document. Metadata information will not be displayed on the page but will be used by the web browser in some form or fashion.
Meta elements are used for various reasons such as adding, keywords, a page description, the author of the document, when it was last modified, and other related information. The <meta>
element is always placed within the head
element as shown here:
<!DOCTYPE html>
<html>
<head>
<title>My Web Page Title</title>
<meta name="description" content="a short description about this web page." />
<meta name="keywords" content="important words or phrases found on this page." />
</head>
<body>
<h1>Main heading</h1>
</body>
</html>
Here are some of the more common meta
elements you’ll be including in your HTML document. There are many more, and you can define your own in a schema.
Copyright
This tag is used to add copyright information to your page.
Description
Search engines sometimes choose to use descriptions to show them the results of searches. Having a description will help your users have a better understanding of the page so they would be more likely to click on your link.
Generator
This tag is not required, but if you use a web publishing application, the application itself may add this tag to your document.
Googlebot
This attribute informs the Google search engine about indexing, archiving, and link-following rules.
noarchive
– Prevents Google search engine from archiving the page.nofollow
– Informs Google that the page can be indexed, but links should not be followed.noindex
– Google robots should follow links, but not index the page.nosnippet
– Prevent Google search engine from saving snippets and archiving the document.
Keywords
Keywords tell the web crawler what the main focus is of the document. It can be used by search engines, although many search engines stopped using keywords with regard to indexing your pages.
Refresh
The web page will display for a specified amount of time before refreshing or switching to a new URL. Note: for redirecting pages, it is preferable to use a URL rewriting method.
Using this meta
attribute requires the browser to support it. It may not work for all of your visitors.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Web Page Title</title>
<meta http-equiv="refresh" content="0;URL='http://anotherhost.example.com/'" />
</head>
<body>
<p>
This page has moved to a <a href="http://anotherhost.example.com/">anotherhost.example.com</a>.
</p>
</body>
</html>
Robots
This tag is not required but can be used if you want to instruct web spiders on how to, or not to crawl your site. Valid values for the CONTENT
attribute are: INDEX
, NOINDEX
, FOLLOW
, NOFOLLOW
.
Multiple comma-separated values are allowed, but obviously, only some combinations make sense. If there is no robots <meta>
tag, the default is INDEX,FOLLOW
, so there’s no need to use this tag if that is your intention. Other possibilities include:
<meta name="ROBOTS" contnet="NOINDEX, FOLLOW">
<meta name="ROBOTS" contnet="INDEX, NOFOLLOW">
<meta name="ROBOTS" contnet="NOINDEX, NOFOLLOW">
For more detailed information about meta and additional attributes, please visit W3.org’s page concerning this topic.