creating html snapshots for google

A recent project required that we use hash navigation for speedy access to content, this also eeded to be indexed well, and seo’d up to the eyeballs, and so i set aboutand creating html snapshots for google.

After reading, becoming daunted and almost put off, i realised that its actually a very simple process indeed!

Google rewrites URLs beginning with /#!/

So, Google rewrites URLS, so instead of my natural URL looking like:
[code gutter=”false”]!/our-expertise/healthcare/partnership[/code]
gets rewritten to:

The site i have build all gets driven from one main script, index.php, so at the top of this, i tested for _escaped_fragment_:

[code language=”php”]
if ( !empty($_REQUEST[‘_escaped_fragment_’]) )
// serve content to bots

.. the rest of my script that drives the regular site for humans ..

Inside of the test for escaped_fragment, i parse the URL and break it into pieces, decipher what content was requested, and serve this up, unstyled and plain html for the bots.

So, creating html snapshots for google was a lot easier than i initially thought!

Here’s the Google documentation for creating HTML snapshots:

Leave a Reply

Your email address will not be published. Required fields are marked *