Search code examples
javascripthtmlseogooglebotdynamic-text

Getting dynamic text indexed by Google


Seems like this should be a common problem, but I can't seem to find it discussed anywhere.

I'm working on a an interactive map - i.e. when you click on one of the markers, it brings up some descriptive text about that location. And I would like to make sure this text gets indexed by Google.

Currently, I'm storing all of these texts in an array, hardcoded in the script. And when someone clicks on a marker, I load the text for that marker into the DOM. The problem is Googlebot just sees it as code and does not index it.

One possible solution I thought of is to store the text in the HTML rather than as an array. But it seems a bit silly to add a bunch of invisible elements, and I'm also afraid that Google may see it as cloaking.

Any thoughts on how I can get Google to index the text?


Solution

    • Do not hard code display:none in your html tags nor in css stylesheet. Set a class for descriptions and apply .hide() on those elements on DOM ready.
    • If you have large descriptions (containing html formatting) rather than few words, You may put them in a separate file and display them using .load(). in this case it would be good Idea to use <a href="descriptions.php?id=x"> where x is the id of description and handle the <a> tag using jquery which translates the href attribute to .load(). So the target page will be crawled by search engines.
    • if you have few words as description, set it as title attribute of <a> tag. Titles are shown automatically or you may apply Jquery to change the way it appears. title attributes are SEO friendly.