Knowledgebase:
Search Engines and Frames
Posted by Markus Paulsen on 07 February 2011 17:12
Search engines have sometimes problems with frames! Frames might make it impossible for a spider engine to find individual pages of a website, or they lead visitors to the "inner section" of a website without the respective frame context. This article explains how you can prevent these problems.

Although more and more webmasters are leaving frames out, they are still commonly used as a navigation and design feature for websites. Let's look at a site with three frames: one for navigation, one for the title and one for the actual content of the pages. The content of the three frames is retrieved from three different pages, according to the instructions saved on a fourth "master page", also known as "frameset page". The HTML source text could for example be as follows:

<head>
  ...
</head>
<frameset cols="50%,*" border="1">
  <frame src="index.html" name="contentsframe">
  <frameset rows="*,4*">
  <frame src="header.html" scrolling="no" name="headerframe">
  <frame src="intro.html" name="bodyframe">
</frameset>
<noframes>
<body>
   To view this page, you need a browser that supports frames!
</body>
</noframes>
</frameset>
</html>

Most spider search engines however only see the respective master page. Similar to an outdated browser, they simply do not understand the instructions used for the assembly of the frame layout. The frames are thus ignored. Only the information between the noframes tags (i.e. data that is on the other hand ignored by a browser that can interpret frames) is read. What would thus be read by a spider engine that cannot handle frames? The result is surely not what you would like it to be:

To view this page, you need a browser that supports frames!

This is not a very useful description of your page! Therefore, we must offer a better description of our website to spider engines! There is however an added problem: Within the noframes section, there are no links to the other pages of your site, which means that the spider engine cannot go beyond the master page. There might be hundreds of pages packed with fascinating information on your website. However, they are simply ignored, due to this simple error and become thus invisible to many spider engines.

The NOFRAMES tag

The problem regarding the description can be solved by adding meta tags to the master page. Meta tags provide however only a limited solution for the problem, as they are not supported by all spider engines. They are also no great help for visitors that wish to view your pages with a browser that does not support frames. There is though a solution available to tackle both problems by means of intelligent design. Have a look at this example:

<html>
<head>
<title>My Homepage</title>
</head>
<frameset rows="*,80" cols="*" frameborder="NO" border="0" framespacing="0">
<frameset cols="*,80" frameborder="NO" border="0" framespacing="0">
<frame src="a.htm" name="mainFrame">
<frame src="b.htm" name="rightFrame" scrolling="NO" noresize>
</frameset>
<frame src="c.htm" name="bottomFrame" scrolling="NO" noresize >
</frameset>
<noframes><body>
<h2> My beautiful homepage.</h2>
If you can read this text, your browser does not support frames. To access the pages of this website, go to the contents list and click the respective links.
<a href="index.html">contents</a>
</body>
</noframes>
</html>

This example looks very similar to the initial page, provided that it is not accessed by a spider engine or with an outdated browser. To cater for these cases, the following additional data has been entered in the noframes section:

My beautiful homepage. If you can read this text, your browser does not support frames. To access the pages of this website, go to the contents list and click the respective links.
Contents
...

The problems is solved. The pages do now contain text which can be read by all spider engines, not just the ones that support meta tags. In addition, we have provided a path for the visitors to access the actual website by means of a link (index.html). To test the above page, click this link. What you see next is the information that is normally displayed in the navigation window. From here, the spider engine can move on through the other pages of your site. If you wish to position the noframes data close to the top of the page, you can enter it immediately after the first framset tag. Do not position the information before the first frameset tag, as this would disable the frame information for Netscape Navigator. Internet Explorer does in any case show the frames correctly.

Body tags within the noframes tags work with virtually all browsers. You can thus rest assured that all browsers and spider engines that might need the body tags can find them. Please remember to always give a title to your frames, even if these titles are not displayed in a correct frame context. For spider engines, titles are one of the key indexing elements. Therefore, all pages should have a title.

Restoration of the frame context

There is one minor problem left to be solved: The spider engines are now able to index the individual pages of your site. However, visitors are not provided with the correct context, which means that the pages will not be displayed in one of the three standard frames. The page remains isolated, which can lead to problems. There are webmasters that do not consider that pages are sometimes shown outside the frame context. Such pages might therefore lack links to other elements of the site, so that inexperienced surfers are "caught" on the page. This might also occur, if you have ignored all tips on how to make your website more accessible to spider engines. The reason for this problem is that certain spider engines such as AltaVista can handle frames. They browse through your site while indexing every page, thus allowing visitors to access pages without any context! There is however a very simple solution available for this: All you have to do is to position a "home" link at the bottom of each page. Have a look at this example:

<head>
...
</head>
<h2> CV </h2>
<a href="index.html" target="_top">homepage</a>
</body>
</html>

You should now see a page without frames as it would be viewed by a visitor who has been brought there by a spider engine. The only available link at the bottom of the page allows surfers to go to your homepage, from where they can continue on using the frames. Please ensure that this link contains a "target=_top" string. Without this string, all visitors who have accessed your pages by the "normal" route and who click the homepage link, would otherwise obtain another 3-frame setup in the body frame.

Another solution is the inclusion of JavaScript. In the following example, JavaScript is placed in the frame pages between the head or the body tags:

<script language="JavaScript">
<!-- if (top == self) self.location.href = "NAME OF FRAMESET PAGE"; // -->
</script>

Replace the section NAME OF FRAMESET PAGE with the name of your master page that contains the frameset instructions. In this example, the page name is index.html, and the script is thus as follows:

<script language="JavaScript">
<!-- if (top == self) self.location.href = "index.html"; // -->
</script>

Therefore: If your website contains frames, follow these instructions to make your site easily available to both spider engines and visitors who use older browser versions.