Tuesday, January 29, 2008

Telling Google WHERE you are in the world

Step 1. Go to http://maps.google.com
Step 2. Go to 'mymaps' tab and create a map, with a pushpin marking your location
Step 3. Hit the 'View in Google Earth' button and save the .kml file
Step 4. Load the .kml file into Google Earth
Step 5. Save the new .kml file from Google Earth (this one is cleaner)

(an alternative to the above 5 steps would be to use http://www.addressfix.com/ (I've just discovered that useful tool!)

Step 6. Edit the kml file in your favourite text editor making good use of the tags and links you can put in there.

Here is a nice example of a .kml file which indicates the kinds of things you can do with the <description> tag:
http://www.seo-expert-services.co.uk/seo-expert-services-london.kml
and in use here.

Step 7. Put a link to the kml file in the sitemap.xml file, like this...
<url>

<loc>http://www.userexperiencedesign.co.uk/userexperiencedesigncambridge.kml</loc>

<priority>0.5</priority>

<changefreq>daily</changefreq>

</url>


Refs:
http://weblog.millionpieces.nl/2007/4/how-to-get-your-information-into-google-maps


Some more advanced KML examples.

Sunday, January 20, 2008

Google Webmaster Tools

Google has some pretty handy Google Webmaster Tools - Dashboard to use to show you how it sees your website.

You can check your robots.txt file here and your sitemap and loads of other stuff.

Add a robots.txt page to tell search engines like google which pages to leave out of the index

There is a good summary of the robots.txt file here: The Web Robots Pages.

These days, you can add a reference to the location of your sitemap here too.

Adding a Sitemap

An interesting Google article asks - What is a Sitemap file and why should I have one?

It is worth adding one to tell google all about your website. It is also worth adding a robots.txt file if you have parts of your website that you would like Google to avoid, or indeed, would like to make really sure Google finds your sitemap!

Tuesday, January 08, 2008

base href does not work for php includes !! (and what to do about it)

Base href is very handy for organizing relative addressing on a website. You may, for example, be working on a project for a client with a directory structure like this:

www.userexperiencedesign.co.uk/projects/cambridge_motorcycles

The 'normal' root of this would typically be www.userexperiencedesign.co.uk but if you want the /cambridge_motorcycles part to be the root, you could define a base href so that all the sub-directories under it would refer to that as root instead. Like this...


<base href="http://www.userexperiencedesign.co.uk/projects/cambridge_motorcycles/\" />


This works GREAT for images and general relative addressing.

I was stumped for a while, trying to figure out why this didn't work for PHP includes. PHP experts would not be so stumped. PHP is handled server side, so the base href in the document is not used. After a lot of head scratching I figured that you could define an equivalent for base href to be used by the PHP includes.

First, you need to define the variable in PHP. Mine is like this...

<?php $root="http://www.userexperiencedesign.co.uk/projects/cambridge_motorcycles/\"; ?>


Then, when you call the include file you do it like this...

<?php include ($root."include/header.html\"); ?>


This gives us a neat way to fake up a base href equivalent for PHP includes. Neat!

If you are an efficiency expert you might worry about how many server calls are made by the PHP includes and whether, when defining $root, you should give the whole path or something relative. My sites are very small so this is not a big deal for me but if anyone wants to leave comments on efficiency (or anything else) I am always happy to learn!