You need to check $this->template. On the homepage it will be 'qa', so for example:
if ($this->template == 'qa')
// do stuff
(It used to be blank in v1.3 and before.)
Other pages are 'question' for question lists, 'ask' when a user is asking a question, 'tags', 'users' and 'search' should be obvious, and 'custom' for any custom pages you make. You can also check $this->request for the exact page (useful for custom pages).