WordPress Tricks: Use a WordPress query to exclude a category from your home page without breaking pagination

Here is the code I use in a WordPress site’s index.php file to exclude a specific category from the home page withOUT breaking the pagination:

<?php if ( is_home() ) { query_posts( $query_string.'&cat=-21' ); } ?>

Of course, to include a specific category, you would use this:

<?php if ( is_home() ) { query_posts( $query_string.'&<span style="color: #ff0000;">cat=4</span>' ); } ?>