Chapter 8. Search Engine Traps

Although search engine technology is getting better, it is still not good enough to index every bit of dynamic content. This is why it is always better to stick to basic text or HTML on your web pages—in theory. In practice, that is not always feasible. If you have to use dynamic content, yet you need to ensure proper search engine crawling, you must be careful how you do it. This chapter goes over many search engine traps and how to deal with them in your code.

JavaScript Traps

JavaScript is a client-side scripting language that runs on web browsers. For the most part, you cannot see this code if you are just looking at a web page. You do get to see some of its effects when you see pop-up/pop-under windows, animations, and so forth.

JavaScript-Generated Content

You will want to put any content you want to index outside the JavaScript code. Here is some example code that shows dynamic text within JavaScript:

<HTML> <head> <title>Example of Dynamic Text</title> <script type="text/javascript"> function defaultInfo1(){ var infoText1=""; document.getElementById('infoblock').innerHTML = infoText1; } function onMouseOverInfo1(){ var infoText1="Product A description goes here."; document.getElementById('infoblock').innerHTML = infoText1; } function defaultInfo2(){ var infoText2=""; document.getElementById('infoblock').innerHTML = infoText2; } function onMouseOverInfo2(){ var infoText2="Product B description goes here."; document.getElementById('infoblock').innerHTML ...

Get SEO Warrior now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.