How To: Make Search Engines Like Your WordPress Blog

Wordpress LogoRecently, I discovered that this site had received a 100% SEO score from Domaintools. When comparing this rating to some larger sites, it seemed Sheeped beat them all by leaps and bounds.

What makes it even better, is that I’ve done relatively little to make my blog search engine-friendly, or “SEO-optimized”. Here’s what I did:

1. Modify page titles

By default, WordPress displays your blog’s name then your article’s name in the title. It should be the other way around. Not only is the article/page name first, blog name last good for SEO, humans like it too. Most of the WordPress themes out there use this approach, but if yours doesn’t or you’re using a vanilla WordPress, you can replace the <title></title> code in your theme’s header.php with this:

<title><?php wp_title(' '); ?><?php if(wp_title(' ', false)) { echo ' - '; } ?> <?php bloginfo('name'); ?><?php if (is_home()) { ?> - <?php bloginfo('description'); ?><?php } ?></title>

This will make your titles look like this site’s (check the title of this page).

2. Use Ultimate Tag Warrior and its meta keyword tag inclusion feature

Using Ultimate Tag Warrior to add specific tags to a post is pretty cool, but what’s even cooler is that you can enable inclusion of these tags as meta keyword tags in your pages. While humans do not directly benefit from this, search engines love it.

3. Use index and follow tags wisely

While it may seem nicer to have Google index everything at first, it’s usually not a good idea, especially on blogs. You don’t want search engines to index your whole site, especially if you’re not using excerpts for your archives. On a typical WordPress blog, there’s at least 4 different pages containing identical contents of a post (date/category/poster/tag/etc… archives). This can be penalized by search engines, but even if it isn’t, they might index the wrong thing. I’d hate to search for something and get a result linking to an article pasted in a blog archive for say, 2007.

This little snippet has helped me out a bunch. It also goes in header.php anywhere between the <head></head> tags:

<?php if(is_single() || is_page() || is_home()){
echo '<meta name="robots" content="index,follow" />';
} else {
echo '<meta name="robots" content="noindex,follow" />';
} ?>

All static pages, posts and the main page will be indexed. Archives and search results won’t. If you’re not using excerpts on your frontpage and are extremely obsessive with optimization and avoiding duplicate content, you may choose to remove the is_home() check. Just be aware that people searching for your site with e.g. “Sheeped” won’t find your front page, but rather some article on your site.

4. Use a robots.txt file to block out unwanted queries

You’ll want to place a robots.txt file at the root of your domain, listing paths and regex matches you do not want search engines to index. The robots.txt for sheeped.com looks like this:

User-agent: *
Disallow: /?
Disallow: */feed*
Disallow: */trackback
Disallow: */wp-admin
Disallow: */wp-content
Disallow: */wp-includes
Disallow: *wp-login.php

It disallows search engines from accessing my control panel (why should they?), my RSS feed (duplicate content!), search queries, and other pages search engines don’t need to index.

5. Enforce or remove trailing slashes from page queries

Similar to duplicate content, pages might be indexed twice with almost identical URLs, the only difference being the trailing slash. You can either enforce or remove trailing slashes from all page queries. Personally, I’ve chosen to enforce trailing slashes, and have touched the subject in my article, “How To: Remove ‘www.’ Permanently With .htaccess“. This can be easily done by modifying your .htaccess file. My .htaccess uses this rewrite rule to enforce trailing slashes:

RewriteEngine On
RewriteRule ^([^\.]+[^/])$ http://sheeped.com/$1/ [R=301,L]

6. Use Google Sitemaps

Having a search engine-readable sitemap in the root of your domain helps search engines index your pages quicker. As I mentioned in my article, “WordPress Plugins a Site Wouldn’t Function Without“, Arne Brachhold’s Google Sitemap Generator plugin for WordPress does everything for you. You just have to install it and enable it. That’s about as easy as it gets!

More to come…

Oh, and let’s not forget the cardinal rule of SEO optimization: The best SEO optimization is writing quality content.

How To: Set Up Ubuntu Linux 6.06 LTS LAMP Server - Overview

Ubuntu LogoThis is my first large how-to. It’s a step-by-step guide through the entire installation and configuration of Ubuntu Linux 6.06 LTS LAMP Server. The how-to has over 32 screenshots and descriptions for each one, allowing anyone to set up their own Linux server with ease.

The how to currently consists of 4 parts:

Part 1: Preparing For Installation
Deals with downloading and burning the ISO image needed to install Linux.

Part 2: Boot-Up and Configuration
Deals with the beginning of the installation and initial configuration of regional settings and networking.

Part 3: Partitioning Your Drives
Deals with partitioning.

Part 4: Completing the Installation
Deals with the final configuration of user/password and LAMP settings, as well as tests if the server works.

Extra 1: Installation Video
Unedited screencast (4.10 mb AVI) of the installation process, starting from Part 2. 19min 32sec total, feel free to skip past the long wait in the middle. Use this as a reference, if anything, not a guide.

It is my intention to make additions and/or other how to’s complementing this one, so look out for more guides on playing with the Ubuntu Server and Linux in general.

How To: Set Up Ubuntu Linux 6.06 LTS LAMP Server - Part 4

Ubuntu LogoThis is part 4 in a series of 4:

- Overview
- Part 1: Preparing For Installation
- Part 2: Boot-Up and Configuration
- Part 3: Partitioning Your Drives
- Part 4: Completing the Installation
-
Extra 1: Installation Video

Part 4: Completing the Installation

Now that you’re done partitioning, it’s time to complete the installation!

Setting Up the Timezone

Select the timezone that best fits you and continue. If you are prompted to use UTC, hit Yes.- The installer will ask you what timezone you’re in. Select the one that best fits you and continue. I’ll choose Eastern. If you are prompted to use UTC, hit Yes (unless you have a reason not to).

Users and Passwords

The first dialog after having entered the timezone asks you for your real name, not the alias you want to log in with.- The first dialog after having entered the timezone asks you for your real name, not the alias you want to log in with.



Enter your desired username. The username should start with a lower-case letter, which can be followed by any combination of numbers and letters. The installer suggests patrick. I’ll go with that.- Now I’m asked for my desired username. The username should start with a lower-case letter, which can be followed by any combination of numbers and letters. The installer suggests patrick. I’ll go with that.


Enter the password you’d like to associate with your account. This password will also be the password you use to perform actions that require ‘root’ access.- Enter the password you’d like to associate with your account. This password will also be the password you use to perform actions that require ‘root’ access. In the next window, confirm the password by typing it again.


Sit back and relax as the installer finalizes the installation.Sit back and relax as the installer completes installing Ubuntu Server on your computer. Let the installation process finish, eject the CD, and reboot your system. Congratulations, installation is done!



Linux should now initialize and prompt you for your username and password. If your screen looks something like this, all went well.Linux should now initialize and prompt you for your username and password. If your screen looks something like this, all went well. Feel free to log in.

Setting up LAMP

It works!Wouldn’t it be great if our LAMP server just worked now, without us having to do anything? Well, it does! Try browsing to your servers IP in a browser, in my case http://192.168.0.6. Woot!


It’s time to do a few changes to our LAMP server. Normally, this would be a 3/4-hour process of manually editing config files and testing. Thanks to Ubuntu though, the installer does it all — better too. All we need to do is choose how we want our LAMP server to work.

By default, Apache2 uses /var/www/ as its document root. We’ll want to change this to our home folder in order to reap the space we’ve allocated.

- Log in, in case you haven’t. Type the exact command mkdir www - This will create the folder /home/patrick/www/ which we will be using as the document root of our server.

Type the exact command: sudo nano -w /etc/apache2/sites-available/default and hit Enter. This will open a text editor with our site’s config file (see screenshot).- Type the exact command: sudo nano -w /etc/apache2/sites-available/default and hit Enter. You will be prompted for your password. Enter it, and a text editor with our site’s config file will open (see screenshot to the right).


Feel free to set the administrator e-mail to your own. Replace all occurrences of /var/www/ to /home/patrick/www/ , where patrick is the username you chose during installation.- Feel free to set the administrator e-mail to your own. Now, go through the document and replace all occurrences of /var/www/ to /home/patrick/www/, where ‘patrick’ is the username you chose during the installation. Navigate around with the arrow buttons. When done, hit CTRL+X then type Y and Enter to save the changes.


- Time to restart Apache to apply the changes. Type sudo /etc/init.d/apache2 restart

- Now, let’s see if this really works! Assuming you’re in your home folder (type cd to make sure), type cd www followed by ls. You should see.. nothing. Good.

nano -w index.php - Make the index.php file so we can test if our server works.- Type nano -w index.php
We’ll create a sample PHP script to test if the server and PHP is working. <?php echo "It's working!" ?> will suffice. Again, hit CTRL + X followed by Y and Enter to save the contents.


Navigate to your server in a browser. It works!- Navigate to your server, e.g. http://192.168.0.5 — it works!

You’re done! Your server is working perfectly!

If you’re uncomfortable with the command-line interface, I recommend you look into guides for installing Webmin and phpMyAdmin for Ubuntu. Also, if you would like to administer your server from your own computer, you can install SSH with the command: sudo apt-get install ssh
You can access it with applications like PuTTY.

In order to install phpMyAdmin (and more) with sudo apt-get install, you will first need to enable the Universe repository. There’s a nice guide on how to do that from the CLI here.

If something went wrong, feel free to ask for guidance in a comment to this article. The Ubuntu Forums has hands-down the best support community you will ever find. If you have any questions or problems, I highly recommend them as well.

Look out for more how to’s on how to use your server for great things.

How To: Set Up Ubuntu Linux 6.06 LTS LAMP Server - Part 3

Ubuntu LogoThis is part 3 in a series of 4:

- Overview
- Part 1: Preparing For Installation
- Part 2: Boot-Up and Configuration
- Part 3: Partitioning Your Drives
- Part 4: Completing the Installation
- Extra 1: Installation Video

Part 3: Partitioning Your Drives

This is the single hardest part to guide anyone through, remotely. All system setups are different so it’s hard to tell you exactly how to set up your system. Whether or not you’re going to be using LVM, how many partitions to make, etc.

The standard options are pretty straight-forward, and I recommend you choose one of them if this process scares the living hell out of you.- The standard options are pretty straight-forward, and I recommend you choose one of them if this process scares the living hell out of you. If you do choose one of them, feel free to skip to Part 4: Completing the Installation.


For the rest of this section, I will show you how I set up my system by manual partitioning. Please take my setup loosely — if there’s something that doesn’t fit you or something you’d prefer, adjust accordingly!

Manual Partitioning

This is the manual partitioning menu. The first two options (if they are shown) will allow you to set up a software RAID and Logical Volume Management. Highlight the drive you wish to partition and hit Enter.- This is the manual partitioning menu. The first two options (if they are shown) will allow you to set up a software RAID and Logical Volume Management. These, if you need them, will have to wait until we have configured our partitions. I will not be configuring either, as they are both unique to each configuration and pretty straight-forward to set up.


I have one harddrive, SCSI1 (0,0,0), a 268.4GB drive. To partition this drive, I’ll highlight it and hit Enter. A dialog will appear, asking me if I would like to create a new partition table, that will delete anything currently on the drive. I’ll hit Yes- I have one harddrive, SCSI1 (0,0,0), a 268.4GB drive. To partition this drive, I’ll highlight it and hit Enter. A dialog will appear, asking me if I would like to create a new partition table, that will delete anything currently on the drive. I’ll hit Yes.


This is the menu after deleting all partitions on the drive. Now I’m ready to set up partitions.- This is the menu after deleting all partitions on the drive. Now I’m ready to set up new partitions.


You can choose to let the installer set up partitions automatically, or you can make them yourself. I’ll select Create a new partition.- Select the “FREE SPACE” entry below the drive and hit Enter. You can choose to let the installer set up partitions automatically, or you can make them yourself. I’ll select Create a new partition.


Our first partition will be the root ( ‘/’ ) partition. This is where all our system files and applications are stored. If you want, you can allocate a percentage of the drive to root, and leave the rest for the ‘/home’ partition.- Our first partition will be the root ( ‘/’ ) partition. This is where all our system files and applications are stored. If you want, you can allocate a percentage of the drive to root, and leave the rest for the ‘/home’ partition. I’d recommend something inside the 15-25GB range for a root you’re going to be using for a long time. Seperating your root and /home is useful if you need to re-install Linux. I’ll assign 20GB to root.


Unless you’re going to have more than 4 partitions per drive, select Primary here. Logical partitions are ‘fake’ partitions created to circumvent the normal limit of 4 partitions.- Unless you’re going to have more than 4 partitions per drive, select Primary here. Logical partitions are ‘fake’ partitions created to circumvent the normal limit of 4 partitions.



Select Beginning. This tells the installer to position our root partition at the start of the available space.- Select Beginning. This tells the installer to position our root partition at the start of the available space.



You can choose to leave everything as it is here. A little tweak: In Mount Options you can choose to turn ‘noatime’ on, which will give you a significant speed boost. It disables generating a new time stamp every time a file is accessed.- You can choose to leave everything as it is here. A little tweak: In Mount Options you can choose to turn ‘noatime’ on, which will give you a significant speed boost. It disables generating a new time stamp every time a file is accessed. When you’re happy, select Done setting up the partition and hit Enter.

Additional Partitions

Now that you know how to set up a new partition, do the following:

- Following the same instructions as before, create a partition in the free space with a size roughly equal to half of your RAM, e.g. 512mb if you have 1GB of RAM. Make it a Primary partition as before, in the Beginning of the free space as well. When you get to the confirmation dialog, highlight the file system type (Use as:) and hit Enter. Select swap area from the menu. Accept the changes. The swap area acts as a substitute if all available RAM is being used.

- Finally, create another partition, but /home rather than /. Ubuntu should automatically suggest this. Have this partition use the remaining space on your drive. Again, you can choose to enable ‘noatime’ to get a performance boost.

Verifying and Finalizing

Your partition table should now look like this (or be similar). If you’re missing the swap space or the /home partition, don’t worry. You can mess around as much as you want. If all goes wrong, delete the entire partition table by selecting the drive itself, like before.Your partition table should now look like this (or be similar). If you’re missing the swap space or the /home partition, don’t worry. You can mess around as much as you want. If all goes wrong, delete the entire partition table by selecting the drive itself, and start over.


If you’re all done, hit Finish partitioning and write changes to disk. A confirmation dialog will appear, asking you if you’re sure you want to apply these changes. Double-check the settings and hit Yes if it looks right.

You’re all done with partitioning! Get ready for the fun stuff in

Part 4: Completing the Installation

If something went wrong, feel free to ask for guidance in a comment to this article.

How To: Set Up Ubuntu Linux 6.06 LTS LAMP Server - Part 2

Ubuntu LogoThis is part 2 in a series of 4:

- Overview
- Part 1: Preparing For Installation
- Part 2: Boot-Up and Configuration
- Part 3: Partitioning Your Drives
- Part 4: Completing the Installation
- Extra 1: Installation Video

Part 2: Boot-Up and Configuration

Now that you’ve downloaded and burnt the Ubuntu Server ISO image, you’re ready to begin the installation. Go ahead and reboot your server with the CD in. If your system does not automatically boot from the CD-ROM, you’ll need to enable this in your server’s BIOS configuration. This option and the method to access it varies from BIOS to BIOS, but generally you’ll be able to enter the BIOS by pressing either F2 or DEL when your computer is starting up. When you’ve reached the BIOS configuration menu (usually blue), look for any option that states “Boot from CD-ROM” or an option that allows you to configure the priority of each drive. Some BIOSes are set to boot from the harddrive before booting from the CD-ROM. Change it so CD-ROM is the first thing your server tries, then save the settings and reboot.

Ensure that the CD-ROM drive is chosen as a boot device before the harddrive and other devices.The screenshot to the right shows how my PhoenixBIOS is configured. The CD-ROM Drive is moved to the top, followed by Hard Drive and other network/removable devices.

Booting Up

Welcome to Ubuntu 6.06 LTS Server. You’re ready to begin your Ubuntu LAMP Server installation! Hit ‘Install a LAMP server’.Your server’s BIOS should now be set up correctly and should be booting from the CD-ROM drive. Hopefully you’re now seeing what is depicted in the screenshot to the right. Great! Now select Install a LAMP server and hit enter. You have begun the installation process.

Configuring Regional Settings

You’re not very far from having a full-fletched server now. Hang on!

Select the language you desire. This will affect the installation and the final system setup. I’ll choose English. Hit Enter.- Now we’ll select the language of our system. Be warned that this is not just for the installation, it is the language your system will use after installation, as well. This is, of course, changeable, but just go with the right language from the get-go. I’ll choose English (it’d suck for you if I chose my native tongue, Danish). Hit Enter.


Select your country of residence. The list varies depending on the choice of language you made before. If you do not see your country or region, hit ‘other’.- Now, similarly, choose your location. The options vary depending on what language you chose in the previous step, so don’t be worried if you don’t see your country listed in the screenshot. If you select ‘other’ you will get a complete listing of languages. I’ll choose United States.


Choose your keyboard type. The option displayed should be the correct one, so just hit Enter if it is. If not, try typing something or going through the list of keymaps.- The installer now asks for your keyboard type. The option displayed should be the correct one, so just hit Enter if it is. If not, try typing something or going through the list of keymaps.


The installer will now configure devices, load additional components, as well as load network hardware. In this How To, I’ll assume that you’re using either ADSL or DSL that does not require authentication. If you’re not, the installation will prompt you to enter the required information.

Configuring Networking

The installer will now ask you what you want to call your server. Call it anything you want, this can be changed later. I will call mine patricks-server. This is not your username, it’s the servers hostname.- The installer will now ask you what you want to call your server. Call it anything you want, this can be changed later. I will call mine patricks-server. This is not your username, it’s the servers hostname. It’s what identifies the server on the network.


And the installer detects more hardware…

Congratulations, you’re done with Part 2. Get ready for the hardest part, partitioning. Don’t worry, I’ll take good care of you.

Part 3: Partitioning Your Drives

If something went wrong, feel free to ask for guidance in a comment to this article.

How To: Set Up Ubuntu Linux 6.06 LTS LAMP Server - Part 1

Ubuntu LogoMany of the people I know crinche when I tell them about setting up their own webserver. They think it’s terribly hard — and they’re right, to a certain extent. Until now, setting up a full-fletched LAMP server that actually works has been a task exclusively for the gifted. Well, no more. Regardless of your skill level, I will guide you through the entire installation process of Ubuntu 6.06 LTS Server, my favorite server distribution to date. It’s easy to use, it’s powerful, it’s secure, and it’s painless to configure.

The Ubuntu Server has no open ports after the installation and contains only the essential software needed to build a secure server.

Thanks to the Lightbox WordPress plugin, you can click on one of the screenshots below and scroll through them by clicking on the “Prev” “Next” links in the upper right and upper left corners of the screenshot window. Descriptions are provided below each screenshot, allowing you to see a slideshow, with commentary, of the entire installation process — without ever having to close the Lightbox window! You may miss out on some information by doing this, but you’ll certainly see the essentials.

Well, let’s begin!

Notice: The screenshots below may be obsolete, as the Ubuntu website has been redesigned. The other parts of this guide remain current.

Part 1: Preparing For Installation

Starting with the basics, we’ll find and download the appropriate ISO image for our system architecture. Then we’ll burn it and commence the installation process. If you’ve already downloaded and burnt the right ISO image, feel free to skip to Part 2: Boot-Up and Configuration. Be aware that “Ubuntu 6.06 LTS” is not the same as “Ubuntu 6.06 LTS Server”. They are two seperate images.

Getting the ISO Image

Click the Server Download link- First off, we’ll head over to Ubuntu.com and click the Server Download link.



On the Download page, select “Ubuntu 6.06 LTS, Ubuntu with long-term support”.- On the Download page, select Ubuntu 6.06 LTS, Ubuntu with long-term support.



Select the region closest to you - e.g. United States. They are mirrors, there’s no difference in content.- Now select the region closest to you. Which you choose is irrelevant (they’re mirrors, thus no difference in content). I’ll select United States.



Select the appropriate image for your system architecture. Unless you’re running a Mac or 64-bit, PC (Intel x86) is probably the right one.- Click on the respective download link for your system architecture. If you’re not sure what to get, chances are PC (x86) is the right one. If you’re running a Mac (NOT the ones with an Intel chipset), get the Mac (PPC) image. If 64-bit, get the 64-bit one, and so on. Please verify that you’re downloading your image in the Server section, not the Desktop, before continuing.

Direct download links: PC (Intel x86), Mac (PowerPC), 64-bit PC (AMD64), SPARC.

Grab a cup of coffee or a coke while you wait :-)
Now grab a cup of coffee or a coke while you wait. You must.

Burning the ISO Image

Now that we’re done downloading the ISO image, we’ll use our favorite burning application to write the ISO to a CD-ROM. It is of utmost importance that you do not just copy the ISO file to a CD, but that you actually burn the image. Most writing applications have a feature called “Write Image”, “Write ISO to Disc”, “Burn ISO”, or similar. In Linux, the ‘k3b’ application (Nero equivalent) can do this with ease, so can Nautilus’ built-in CD writer (right-click the ISO in Gnome). Please see “How to Write ISO Files to CD in Windows” for Windows instructions, and “How do I burn an ISO image to CD in OS X? for Mac OS X instructions.

Get Ready to Install

When you’ve written the ISO image to a CD-ROM, please verify the contents of the disc. There should be several files and folders — if there’s only an .iso-file, you haven’t burnt the ISO. Please see the above instructions on how to burn it rather than copying.

If all looks fine, you’re done with Part 1! Let’s try it out in

Part 2: Boot-Up and Configuration

If something went wrong, feel free to ask for guidance in a comment to this article.

How To: Remove ‘www.’ Permanently With .htaccess

If you’ve ever tried to remove the ‘www.’ prefix from your URLs in Apache by rewriting them (find out why you should), you may have found that it was harder than you’d imagined. Why are URLs ending with a trailing slash modified while others aren’t?

You’ve probably had a rewrite rule that would redirect URLs like www.sheeped.com/test/ to sheeped.com/test/, but not affect www.sheeped.com/test. You’re experiencing a trailing slash problem.

Excerpt from the Apache mod_rewrite guide:

Every webmaster can sing a song about the problem of the trailing slash on URL’s referencing directories. If they are missing, the server dumps an error, because if you say /~quux/foo instead of /~quux/foo/ then the server searches for a file named foo. And because this file is a directory it complains. Actually it tries to fix it itself in most of the cases, but sometimes this mechanism need to be emulated by you. For instance after you have done a lot of complicated URL rewritings to CGI scripts etc.

If you fix the trailing slash problem prior to removing the ‘www.’, every URL starting with ‘www.’ will be changed, even those lacking a trailing slash. The trailing slash fix alone is also useful if you want to enforce trailing slashes to avoid search engine problems.

This .htaccess bit removes all ‘www.’s from anything, and adds a trailing slash on anything but files with extensions (.gif, .php, etc.):

RewriteEngine On
# Fix trailing slash problem
RewriteRule ^([^\.]+[^/])$ http://sheeped.com/$1/ [R=301,L]
# Remove www., always.
RewriteCond %{HTTP_HOST} ^www\.sheeped\.com$ [NC]
RewriteRule ^(.*)$ http://sheeped.com/$1 [R=301,L]

Try it out with this ‘faulty’ URL (look at the address after the page has loaded): http://www.sheeped.com/2007/01/03/back-on-track

If you do not need to implement a trailing slash fix, you can just use the second rule to remove ‘www.’ from your domain:

RewriteEngine On
# Remove www., always.
RewriteCond %{HTTP_HOST} ^www\.sheeped\.com$ [NC]
RewriteRule ^(.*)$ http://sheeped.com/$1 [R=301,L]

—–

Notice: The afore-mentioned trailing slash implementation does not always work. All Apache setups are different. In fact, many of them are set up (cleverly enough) to not need trailing slash manipulation. I thought of the trailing slash fix not because it was a fix-all-problems solution for everyone, but because that is what has worked on all of the (often poorly set up) shared hosting and specific software I’ve used. If you are using software with periods in its file or directory names, this implementation will not work for you, as it does not allow it. Regex-savvy individuals will notice this immediately when looking at the rewrite pattern.

Update: I’ve been asked why I thought of the trailing slash fix when the original ‘www.’ removal works perfectly. Well, it does not — not always. Many will have implemented this and then realize that whenever they try to access software located within a directory on their website without adding a trailing slash, the site will load, but the ‘www.’ suffix has been magically re-appended, regardless of whether it was previously removed. This is exactly what has happened on almost all of the shared hosting services I’ve used, and it causes annoying problems with cookies and what not. Furthermore, the automatic inclusion of the trailing slash will prevent search engines from indexing the same page twice, one with a trailing slash and one without.