I think SEO might be a scam

April 2, 2010 Leave a comment

Like many other bloggers and website owners, I subscribe to several RSS feeds that provide various SEO tips and tricks. I do it because, like a surgeon, I want to be up on the latest techniques. But the whole thing is starting to turn me off, and I’m ready to unsubscribe from all of them.

Here’s the problem.

I’ve found that most sites that provide SEO or online marketing tips are very thin on content, or have the same content as other sites. I can find a hundred sites that tell you how to optimize your meta tags or tell you how to be a good guest blogger. They post once or maybe twice a week, and it’s the same generic posts that an autogenerator could write.

Why is that a problem?

Because they’re running two or three other similar sites where they also post once or twice a week. So instead of posting three times a week on one blog (3×1), they can maximize their income by posting once a week on three blogs (1×3) because three blogs plastered with affiliate ads make more money than one. They almost meet the definition of “made for Adsense” sites, don’t they?

It just reeks of money-making sleaze, while the readers desperate for content keep getting strung along. I don’t know how many bloggers have more than one blog, but I’ll bet the number of “SEO” or “marketing” bloggers that have multiple blogs outnumbers the rest. With software like WordPress, it’s easier than ever to perpetrate this scam.

The biggest issue is that I can’t figure out how to apply that generic content to my non-generic site. Until I find a “SEO” site that gives specific advice, I’m tentatively writing off the entire industry.

I swear, one of these days I’m going to write a “SEO Post Generator” in PHP or VB, to show how easy it is to write something that targets a large audience. I guarantee it will pass the Turing test. At the very least, there should be a “online marketer” drinking game where some use could be made out of all the fluff. Take a drink if:

  • You see the word “blog” or any form of it (blogger, blogging, etc) more than five times in one post
  • A “blogging tools” links post
  • A post that tells you what you “should” be doing as a blogger (i.e. “Are you making the most out of your blogging opportunities?”)
  • A generic “issues” post such as “how to make money blogging” with the requisite links to money making sites with very little description of what they’re about.

So now I’m in this weird place where I see this going on with one or two sites, and it starts turning me off to every other SEO blog as well, even the ones I know are good. I see the same things on all of them: the very generic content (intended to generate as much traffic/sales as possible by painting a very large target with a broad brush), the scare tactics (i.e. “if you don’t use SEO, you’ll be at the bottom of every Google search!”), and especially the post titles which themselves are SEO-optimized to attract clicks (“How to make a fortune blogging”, “75 Tips for Blogging Success”, etc).

Even this article itself could be accused of many of the same things. It’s actually pretty generic. Ugh, now I’m disgusted with myself.

Categories: SEO Tags:

Show category icons per post

March 1, 2010 13 comments

You may like to show icons in your single posts, or search results pages, corresponding to the post’s category. I know I do. For example, if you have a “SEO” category, you want to display a related icon whenever a post in that category is displayed. It adds a certain spiffiness to your posts, as well as a bit of color. Here’s how I do it.

Read more…

Categories: Uncategorized

Ultimate SEO Best Practices, Tips & Tricks

January 25, 2010 5 comments

I’ve compiled this list as a compendium of tips from many different websites, as well as things I’ve learned through trial and error. This list is in no particular order, but its purpose is to focus your attention like a laser on specific techniques that have helped me build my blog, and can help you too. These are all white hat techniques, so don’t expect to see any shortcuts to PageRank or higher SERP ranking. There’s no trickery or sleight of hand involved. This is hard work and there’s no easy way to make it to the top. Most of these tips are slanted towards WordPress users; I noted this where applicable.

Host your blog on your own domain.

This site is hosted on wordpress.com, only because I’m a part-time SEO blogger and don’t have the time or desire to set up an entire site just for the occasional article about WordPress. But whatever you choose to write about, if it is your primary activity, do it from your own domain.

Avoid services like blogger.com and wordpress.com, which limit what you can do “under the hood”. You won’t have direct access to many system files that can be tweaked to make your site better. Also, should the service go pay (or go under), you might get locked out of your site and lose all the content you spent a lot of time creating. You want to have a site that is fully customizable and yours.

Reasons not to use a free hosting service:

  • It can make your site appear less professional than a self-hosted site.
  • The PageRank isn’t yours.

Free-hosted screams “not serious.”

Self-hosted screams “I am a dedicated blogger who knows what s/he’s talking about.”

I pay $10 a month for hosting and $30 per year for domain name registration: a very small price to pay for the benefits of having a self-hosted site (please don’t contact me to tell me you can get it cheaper). Don’t be afraid; you don’t have to become a website coding expert to run your own site.

For blogging software, I recommend WordPress, but I know there are others. Try out different ones and see which one you are comfortable with. WordPress is very easy to set up and maintain, and there are hundreds of plugins and tutorials that make it easy to do whatever you want with your blog. If you’re on the fence, here’s the article that got me to switch: I ditched Blogger

Scroll down that post and you can read my comment from when I was still using Blogger. I switched less than a month later.

Decide on a theme or niche for your site, and give it an appropriate name.

Figure out the main subject for your blog, and stick with it on pain of death. It has to be a real subject, not “Random Thoughts from My Head”. Sorry, but nobody reads those blogs (not even your friends). The name of your blog has to reflect the subject. Don’t skimp on the time spent on choosing the name and subject of your blog, they are very permanent and should never change.

Choose a domain name with one or two major keywords from your site.

If you run Al’s Chicken Shack, alschickenshack.com would be a good choice (hear that, Al?). My site is Code For Excel and Outlook, so I chose codeforexcelandoutlook.com. You should do the same, but try and keep it to 25 characters or less. In general, the URL and the name of the site should be the same.

Register both the .com and .net version of your hostname, and unless you have no choice, avoid any of the others.

Let’s face it, there are 15 or so top level domains, but after 20+ years, .com and .net still rule. You need to have the .com version of your domain, and the .net version as well, so that someone else can’t register it and take traffic away from your site. You might also want to consider registering common misspellings of your domain name, or other variations (such as als-chicken-shack.com and als-chickenshack.com).

Avoid TLDs like .info and .biz, in my experience those are bad neighborhood domains that attract spam. I’ve never seen a legitimate website on one of those domains, and when I do, it takes me a long time to trust that the site isn’t a splog. Domains with country codes are OK, everyone understands that it means you are from a certain country (.uk for England, .pt for Portugal, and so on) and won’t subconsciously penalize your site.

Create an authority site.

What does that mean?

What does an authority site do? What does an authority site look like?

You want to be perceived as an authority in whatever niche you choose. That means:

  • Don’t write about topics outside your niche.
  • If you blog about animal photography, don’t publish posts about knitting fuzzy sweaters. Ever. Set up a separate blog for that. Even better, don’t blog about animal photography, write about photographing bears. The more specific, the better.
  • Link to articles or sites outside your niche as the exception, not the rule.

You might love that site you found that has articles about your local football team, but unless you’re writing a local sports blog, keep that site in your browser favorites, not on your blogroll. Feel free to mention it on Twitter, though.

You might be asking why you should stick to a niche. Here’s why: If you post about multiple, unrelated subjects, search engines are less able to categorize your content. They’ll have trouble deciding when your content is relevant for a particular user’s search results. Remember these are automated programs, they have to make decisions based on pre-determined algorithms. If someone does a search for “knitting” and I’m a computer program, which site am I more likely to display, one that writes ONLY about knitting (more authority), or one that writes about knitting, photography, cooking and maternity?

Think about it in medical terms. If you had cancer, would you go to an oncologist, or a general practitioner? That is the same decision search engine users make when deciding where to go for information.

(Although lately, it seems like search engines are returning mostly paid links and product links at the top of their results, instead of information, but that’s a topic for a different article.)

Your readers are also confused and are less likely to stay if one day you write about something they like, then the next day write about something they don’t, especially if its an unrelated subject. They’re more likely to think of you as flighty and not an authority on anything. They’re doing internet searches to find out information, not to read whatever random spewage comes out from your fingers. Ever heard the phrase “jack of all trades, master of none” ?

Linking outside your niche also confuses search engines. It can make your site appear to be a link farm, because that’s what link farms do — collect links. You don’t want your site penalized as a link farm, and you don’t want it to appear that way to casual visitors.

Don’t submit your own articles to StumbleUpon, Digg, Delicious, etc.

Let others do that for you. Those sites exist for others to bookmark and popularize your content, not you.

Set up an account at Technorati.

Technorati used to be at least partially useful. You could comment on a blog, submit it to Technorati (via http://technorati.com/ping) for them to scan, and then your own blog’s authority would increase when their scanner saw your URL in the comment. But at some point in 2009, Technorati changed their algorithm for calculating blog “authority” (which was already subjective, like Alexa, since it only includes user-submitted blogs) to something I can’t understand. They redesigned their page so navigation is a nightmare, the ping feature (where you would tell Technorati to scan a new site) was permanently turned off. So now you have to wait for the site owner to submit their own blog, instead of being able to submit any site to the so-called “blog indexer”.

The worst part is that through all of their changes, the “noise” has remained — look at all the splogs, link farms and fake blogs that are sprinkled through the search results.

Now, Technorati looks like yet another superficial pop-culture news site (with an especially ugly color scheme). They basically programmed themselves into irrelevance.

So my suggestion is to submit your blog (don’t ask me how, I can’t find the submission link anymore), and spend no more than 10 minutes a week on the site doing keyword searches for other blogs in your niche. Favorite them, then visit them and leave a meaningful comment. This isn’t so much about using Technorati as it is about building a community around your blog.

Avoid blogrolls, or at least keep them short.

And make sure the sites are directly relevant to your niche (see Create an authority site above).

Don’t submit your site to directories, unless you’re actually participating in the community.

It’s tempting to add your site to every directory you find, but 99.9% of them are just link farms (I subscribe to the “bad neighborhood” theory, and you should too). Only submit your site to Google, Google Blogs, Yahoo, Bing and DMOZ. Everyone else will catch up.

Submit your site to places like BlogCatalog (another mostly useless site unless you happen to blog about blogging) only if you are going to participate in the forums. That’s how you build your authority. If you sign up for a hundred directories, set up a basic profile and drop your link, never to come back, all you do is ruin your reputation (most of them are nofollow links anyway). And never, ever use a submission service (either paid or free) that claims to submit your site to multiple search engines. See Search Engine submission services are a scam if you don’t believe me.

In short, you should only be submitting your site to a search engine from that search engine’s website, not from a third party site. There’s no substitute for hard work!

Always credit content if you didn’t create it.

It’s for your benefit to give credit if you borrow an idea. Throwing in a link has several major benefits:

  • You increase your authority by associating yourself with other established bloggers in your niche.
  • You increase your authority by showing that you are honest and give credit where it belongs.
  • You increase your authority by showing that you know how to take someone else’s idea, add to it and give your opinions in a professional manner.

When writing a post, you should do a quick search to see if others have written about the same subject, and add a link to their posts in yours (where appropriate; over-linking isn’t recommended). That’s how you continue to build your community authority.

Most webmasters are smart and probably have a Google Alert set up with their blog URL or some important keywords. Or they’ll see the hits from your site in their logs. They’ll be able to find your post and comment on it, or even add a link to your site in their blogroll. Or, if you use WordPress and link to another WordPress blog, a trackback is sent automatically (if configured) to the other blog. This benefits both blogs.

When you leave a comment on a blog, make sure a link to your blog is in the “Website” field.

Every blog has a comments section, and every comments section has a place where you can put your blog URL. Use it! Make sure you use the same URL as the one you used when you registered with Technorati. This is a must and you should never fail to put your link here, especially since it’s one of the very few times your URL will actually be asked for.

After commenting, you should immediately go to Google and/or Google Blogs and have them spider that blog. You might also want to consider submitting the post to StumbleUpon, Digg, Delicious, etc, because some of those visitors will see your comment and visit your blog, resulting in bonus traffic on top of the traffic you get from the comment you left.

Only blog on weekdays.

Pick a schedule and stick to it. You can post infrequently, but not erratically. I blog only on weekdays because nobody reads blogs in my niche (programming) on the weekends. The people that come to my main site are doing searches to find help with Microsoft Office programming, so they’re most likely at work and stumped on a problem. If I post on a weekend, the post will just be ignored (since nobody is at work) and it won’t generate significant traffic. But this is blog-dependent, so experiment and see what works for your niche. You might find that weekend posting generates huge traffic for you.

Only write one post per day.

Your articles need time to “sink in” and draw traffic. If you publish something immediately after, you limit the post’s value and bury it in your archive. You also want to build anticipation for your next post. Posting more than once a day, or too frequently, will dull the excitement.

Don’t submit articles to article submission sites like EzineArticles.

This might seem counter-intuitive, but unless you’re a prolific writer who produces volumes of content, all you’re doing is giving away content for others to use (royalty-free), while helping EzineArticles to a big spoonful of search engine traffic that would have otherwise gone to you if you had published the article yourself on your blog. At best, you should submit one or maybe two articles you can afford to lose, and the content should not duplicate anything already on your site. Make sure there’s a prominent link to your site in the article.

Make it easy for others to subscribe to content.

Make sure RSS buttons for your feed are displayed prominently on each page (I have them at the top and bottom of each page). If you use WordPress, there’s a plugin called “Subscribe to Comments” which you must use (if you use it, consider donating to make sure it stays updated for future WP versions). After commenting on a blog post, it sends an email to the commenter when another comment is posted, making it easy for your commenters to read future comments and return to re-comment. (Wow, I just used “comment” seven times!)

Use Google Blog Search (http://blogsearch.google.com/?hl=en&tab=wb) to find other blogs in your niche.

As above with Technorati, dedicate about 10 minutes a week to this. Visit and comment. Add the “keepers” to your blogroll so you can comment on them again later.

Build your personal blogroll.

You follow other blogs, don’t you? You should already be using a feed reader to read articles from other interesting blogs. I use Google Reader (the online service), but there are many others. I use Google Reader for several reasons, mostly so I can read my favorites from anywhere (home, office, on the road, etc). They don’t have to be blogs in your niche. But make a point of building a list of blogs in your niche that you read, follow and comment on regularly. Participate in the community and you will reap the benefits in increased traffic and authority.

Try to be the first commenter on a blog post from your personal blogroll.

When you are the first commenter on a blog post, you tend to get more attention both from the post author (since you appear to be paying attention and interested in the blog) and from search engine visitors (since its often the first thing they read after the post). The first comment is very easy to spot since it bookends the comments. The first commenter will often set the tone for the resulting discussion. Trust me, you want to be this person, as often as possible.

This means using your feed reader to watch for new posts on your favorite blogs, and commenting as early as possible. Some feed readers can be set to notify you instantly when a new post is picked up from a feed. You can then jump onto the blog quickly and see if you can add anything of value by way of a comment. Remember your reputation, however, and don’t comment on everything you see just to be first. Commenting only where appropriate is more important than commenting first.

Create a sitemap and set up auto-pinging for your blog.

A sitemap is (usually) an XML-based list of your posts and webpages. It is a readable index intended for use by search engines to find content on your site and manage its own index. By “auto-pinging” I’m referring to the automated process your blog uses to inform various search engines and feed readers of a new post or page on your site.

If you use WordPress as your blogging platform or CMS, this is simple (another reason to use WordPress):

  1. Install and configure the Google XML Sitemap Generator
  2. Go to Settings » Writing (wp-admin/options-writing.php) and enter the following URLs in the “Update Services” box at the bottom of the screen:

Replace http://path/to/your/sitemap with your hostname and path to the sitemap you created above (the plugin can tell you the path). Replace http://www.url.of.your.feed.here with the URL of your main RSS feed. You can add extra lines if you have extra feeds.

To ping Google Blogs, go to their ping page and enter the URL for your feed and click Submit. Copy the resulting URL from the address bar into the Update Services box in WordPress. To find the URL for other sites (NewsGator, BlogLines, etc), just do a search for “ping newsgator” and make a note of the URL. You can also do a search for “ping list” but make sure it’s a recent list. Or just go to the site and ask them if they are ping-able.

If your site is in good old HTML:

Search for an XML sitemap generator (ex: http://www.xml-sitemaps.com/), create your sitemap and upload it to your site, making note of the URL. You’ll need to update it every time you add a new page.

Visit http://www.kping.com/ and register for an account. Select the services you want to ping. Remember not to ping too many, you don’t need most of them. You can also ping manually, by creating the ping links from above and cut and pasting them into your browser address bar periodically (eg: once a week). Trust me, the dual solution of WordPress plugin and Update Services settings is much easier since it does ALL the work for you. This functionality alone was one of the major reasons I switched to WordPress.

Why do we need to do all of this? See http://en.wikipedia.org/wiki/Site_map for the benefits of a sitemap. When you have a sitemap on file with each of the major search engines, you allow them to index your site properly. Whenever you add a post or page to your site, you’ll need to update the sitemap and then let each of them know it’s updated. WordPress lets you do this automatically, but if you don’t use it, King Ping can monitor your site for you.

Set up accounts with Google Webmaster Tools, Bing Webmaster Center and Yahoo! Site Explorer to monitor how they are indexing your site.

Do a search for each of these services, login and register for accounts and give them the URL for your sitemap (these are the sites you’ll be pinging from your blog). You may have to add a meta tag to your site to validate it, but its worth it. In return you get crawl statistics, better indexing, information on pages not found, how many pages from your sitemap are in the index, keyword ranking, and so on. All for free.

Leverage Google Alerts.

Google alerts is your silent partner. It can help you find other blogs in your niche, and content thieves stealing from your site. Just go to Google Alerts and set them up for your blog URL, and any keywords you want to search for. You’ll get a daily or weekly email with the search results. If you blog about teddy bears, a Google Alert for “teddy bears” will show you if anyone else is talking about the same thing. You can then visit that blog or site, leave a comment, add the site to your blogroll or feed reader, file a DMCA complaint, etc.

Get a gravatar.

A ‘gravatar’, or globally recognized avatar, is a small picture that appears next to blog comments or in forums where its supported. It’s ‘global’ because it follows you across multiple blogs. Just visit http://www.gravatar.com, upload your photo (ideally a head shot) and the same photo will appear next to all of your comments on blogs or sites where gravatars are supported!

The reason for this is simple. On a lot of blogs, if you don’t have a gravatar, a default image is substituted. You don’t want to appear anonymous, especially if you plan on being a regular commenter on several blogs. You want to appear serious about this “blogging” thing. You can distinguish yourself from the other “comment-and-run”-type blog commenters by uploading your photo to gravatar.com and using the same email you usually use to leave blog comments. If you comment using multiple email addresses, you’ll need to set up a gravatar for each one (ideally, the same photo).

Say no to dofollow sites and link exchange requests.

Link exchange only “works” (in the authority-building sense) if the two blogs exchanging links are in the same niche. Exchanging links just to get another inbound link, without regard for the relevance of the site you are linking to, will damage your reputation. I’m not even referring to PageRank at this point. You may even see a slight increase in PageRank, but this will be offset by a corresponding decrease in your authority.

Commenting on dofollow blogs is a phenomenon I’ll never understand. Looking for and blindly commenting on blogs simply because they don’t use rel=”nofollow” (even if the blog is completely unrelated niche-wise), just to drop your link, is a short term strategy with long term loss. Search engines know when two unrelated sites are linking to each other and know how to discount the value of mutual links.

As long as we’re on the subject, all the nofollow tag does is stop PageRank from flowing to the target URL. It doesn’t stop PageRank drain from the source. The nofollow tag only determines whether the lost PageRank disappears into the ether (rel=”nofollow”) or flows to the target. Please don’t contact me to argue about PageRank and nofollow.

So if you don’t want to lose PageRank to an external URL, don’t link to it at all.

Look for forums or mailing lists related to your niche.

Chances are there’s a forum, newsgroup or mailing list on the subject you write about. Join it and actively participate, but never drop your link unless its directly relevant (links in signatures are usually acceptable, but check local practices first before doing so). If you don’t find one, create it! Chances are good that not every social network has a forum for your niche. Check sites like LinkedIn, MySpace, Facebook, Yahoo Groups, and if you don’t find your forum, find out how to create it. Choose sites that already have reputable traffic.

Write good content.

I can’t believe I have to write this, but it’s necessary because there are many bloggers who suffer from the unfortunate combination of poor writing skills and inability to evaluate themselves honestly.

The way I approach it is: If I were a stranger, visiting my own website, would I read the articles?

Be honest — don’t sugarcoat or rationalize your writing.


I hope you enjoyed this article. The comments section is important to me. Feel free to add any more killer tips in the comments.

Categories: SEO Tags:

How I sped up my WordPress blog

January 18, 2010 4 comments

I thought I’d share some tips on how I cut down the loading time for my blog. These tips might help someone out there make their WordPress blog (or any website) run faster. So far, using these techniques, I’ve shaved about 2 seconds off the loading time (when cache is empty) and for repeat visitors, the load time is under 7 seconds. Testing performed using OctaGate SiteTimer. As usual, FireFox and Safari browsers were much faster than Internet Explorer.

Compact (“minify”) your CSS, PHP, JavaScript (JS) and HTML Files

Removing whitespace, unnecessary lines, and useless code from these files will shrink file size, improving download time of these files, at the expense of (possibly) making the files slightly less readable. This is the easiest thing you can do with these files. There are even online “compressors” where you can upload or cut and paste your code, and it will spit out the compressed version, but I wouldn’t use that unless you understand the output. Obviously, it helps greatly if you understand CSS, PHP and so on, so you can edit and compact the code yourself.

Remove comments and commented code from your active files and paste them into local backup files. I keep them on my hard drive, where I can make notes on what they’re for, in case I do eventually need them. Some CSS files even have whitespace (empty spaces) at the end of the line. If you press the “End” key, you can see where the true end-of-line is, and backspace over it to remove the wasted space.

And as I’ve found the hard way, WordPress will still process code inside comments, while leaving it commented out. So commented code (especially with PHP or database calls) will needlessly waste processor time which could be used to display your webpage. Weigh the benefits of keeping commented code in your blog’s PHP files versus removing it to decrease file size and save processor cycles. Again, I remove unused code, comment it, and save it on my hard drive if needed later.

Google has an excellent Firefox addon called PageSpeed which can show you where your CSS is inefficient or unused.

See 10 Tips For A Smaller CSS File for specific examples of how you can shrink your CSS file.

Many PHP-based themes for WordPress also use comments and whitespace in excess. Removing the whitespace and concatenating lines where possible will result in smaller file sizes.

Your blog may also benefit from conditional includes, which will have the double benefit of shrinking your file size and providing dynamic content. The process is identical to the process for creating external JS files: include a link to the PHP file, and in that PHP file, remove the opening and closing PHP tags. Make it conditional by using if statements.

Move CSS to the top, and JS to the bottom

Page load time will also benefit if you move CSS links to the top of the page, and JS links to the bottom. Anyway, this is what Yahoo recommends in their webpage optimization guidelines. JavaScript that isn’t essential for the operation of the page (ex: visitor tracking code) should be placed in the footer or at the bottom of the page, so the main content can load first. If you run WordPress, this is easy; there are a few “move Javascript to footer” plugins. I use JavaScript to Footer.

JavaScript should also be externalized, to shrink overall HTML file size. See Reduce The Size Of Your HEAD and scroll halfway down for instructions on how to create external JS files.

Remove unnecessary Plugins, and make the remaining ones conditional

Are you using 10, 20, 30+ plugins? Some plugins are processed every time a page is loaded, even if they don’t actually do anything on that page. For example, some plugins hook into the wp_head function to place CSS or JS links in your header, which will be loaded on every page even if the plugin isn’t being used on that page.

Can you remove them, or find a “rollup” plugin that can do the work of two or three of your existing plugins?

A popular class of plugins for WordPress are the ones that interact with Google Analytics. The one used on my blog is Google Analytics for WordPress. This plugin automatically inserts your Google tracking code into your posts and pages. But I can duplicate the effort by simply pasting in Google’s tracking code directly into footer.php of my theme, thereby saving time having the plugin do it. Just go to your Google Analytics account and get the tracking code, and paste it into the PHP file. Sure, I might have lost some of the functionality of the plugin, but all I really need is the basic reporting function of my Analytics account.

Another popular plugin is Feedburner FeedSmith. This plugin detects all of the ways your feeds can be accessed, and redirects them to your Feedburner feeds. That way, you can aggregate all your subscribers under the FB feed, making your subscriber count more accurate, and making sure all your subscribers are seeing the same content.

But all I had to do to get rid of this plugin is visit What is My WordPress Feed URL? and then edit my .htaccess file to redirect the built-in WP feeds to my FeedBurner feed.

Redirect 301 /blog/feed/ http://feeds.feedburner.com/MyFeedName
Redirect 301 /blog/feed/rss2/ http://feeds.feedburner.com/MyFeedName
Redirect 301 /blog/feed/rss/ http://feeds.feedburner.com/MyFeedName

and so on.

I got rid of the Random Posts plugin by using code I found on the ‘net that returns random posts using a WordPress function.

I am also using the Similar Posts plugin (from the same author) in my post footer, and if I didn’t mind changing it to random posts instead, I could use the above code as well, and remove two plugins.

Check your plugins and see if any of them don’t need to run all the time. For example, if you run a plugin that allows visitors to email or print a copy of a post (ex: WP-EMail, WP-Print), you probably don’t need them to run if the visitor isn’t on a post page. Make them conditional instead. This sometimes requires direct editing of the plugin code itself.

  1. Deactivate the plugin
  2. Click the “Edit” link to edit the plugin file itself
  3. Wrap the entire plugin in an if statement that checks the current page. Don’t forget the opening and closing braces “{ }”
  4. Save the file and reactivate the plugin.

This will be most successful with plugins that write CSS or JS links inside your head tag, because this hack will stop them from doing so, thereby decreasing load time for pages where the plugin isn’t necessary. If you got a fatal error when editing/reactivating, or your blog breaks, or the fix simply doesn’t work, you might need to search the plugin file (deactivate it again first) and look for the section where the CSS or JS file is written, and add the above code there instead.

Once editing is finished, the plugin will only run where we want it. See WordPress Conditional Tags for a complete listing of conditional tags. Remember, you’ll need to repeat these steps every time a plugin is updated, because the hack will be wiped out by the update. It will be easiest if you deactivate the plugin, update it, then hack it, before reactivating it. Also, for those plugins you need to call manually in your template, you’ll want to go through your template files and wrap the function calls in an ‘if (function_exists(plugin_name))’ statement, because you’ll be deactivating it a lot and you don’t want your blog to break every time you need to update a plugin. In fact, I recommend you do this for all plugin function calls, even the ones you won’t be editing, because someday you might need to deactivate one.

Certain plugins don’t need to be running around the clock, and can be safely deactivated and reactivated when needed. For example, I keep the following plugins deactivated until I need them:

  • WordPress Database Backup
  • WordPress Automatic Upgrade
  • Optimize DB
  • Maintenance Mode

Although it might actually be better to remove them completely and reinstall them when needed, since all plugins (even deactivated ones) are checked to see if they apply to a current page. Very inefficient on the part of WordPress, but that’s the way it is, and this is an article about speed and optimization after all.

Use compression

If using WordPress on a Unix-based host, try and use mod_deflate or mod_gzip. Some cheap webhosts won’t allow you to use it, however, because they are resource hogs. As an alternative, you might be able to use PHP-based compression (zlib). It depends on your webhost. See Compress your WordPress website for more.

Got additional suggestions? Post a comment with your thoughts.

Categories: Tips Tags: , , , ,

Compress your WordPress website

January 11, 2010 13 comments

    This tutorial (like most of the others found here) assumes you are running your WordPress site on a Linux/Apache configuration, and you have direct access to your .htaccess file. This article will teach you how to compress all the JavaScript, CSS, PHP, HTML for your WordPress site, which should result in a faster site with less burden on your server (especially if you use shared hosting).

    Note that these techniques are a compendium of advice found on various websites such as

    First you should go to http://www.websiteoptimization.com/services/analyze/ and check the results for your website or blog. You should see .js, .css, .php and .html files are all being transmitted as full-size by the server. You might also want to check ismyblogworking.com for more compression stats.

1. Compress JavaScript

    To compress the JavaScript on a site-wide level, you’ll need to create a PHP file called compress_js.php (really it could be called anything, but we want an obvious name). Put it in your root folder (although technically it could be placed anywhere). Here are the contents of compress_js.php:

<?php
ob_start ("ob_gzhandler");
header ("content-type: text/javascript; charset: UTF-8");
header ("cache-control: must-revalidate");
$offset = 60 * 60;
$expire = "Expires: " . gmdate ("D, d M Y H:i:s", time() + $offset) . " GMT";
header ($expire);
?>

    This starts PHP’s output buffer. It sets an Expires header, so the script will not only be compressed, but also cached for a short period.

Then add the following into your .htaccess file (or create one if needed):

# javascript compression
ForceType application/x-httpd-php
php_value auto_prepend_file http://www.yoursite.com/compress_js.php

    This tells the server that any JavaScript files should be processed like PHP files, with compress_js.php (our super-duper compression/cache code from above) pre-pended to each PHP file. This is site-wide, so ALL JavaScript files (including ones from your theme and any plugins) will be passed through the script!

    Now go back to http://www.websiteoptimization.com/services/analyze/ and check the results. Any .js files should now show as compressed.

Congratulations! On to CSS compression.

2. Compress CSS

    This one is a bit tougher, because the CSS files must be in their own folder with no other files. Generally this would be a subfolder of your theme or a plugin. Some plugin authors do not use CSS subfolders, making this a tough hack! Once you do it a couple of times, however, it will get easier.

    If the CSS file(s) you want to compress are not in their own folder, create a subfolder called css and put it/them there. You may want to disable the plugin you’re working on to do this. If you’re doing it to WordPress, a plugin like Maintenance Mode should be used so that visitors don’t see any weirdness while you’re moving css files around.

    This is a plugin hack, so unfortunately you’ll need to repeat this process every time you update the plugin (unless you update manually). Fortunately it only takes a few moments to do this. I encourage anyone reading this to write to their favorite plugin developer and ask them to abstract out their CSS (if any) to a subfolder, to make this process easier. Even better, ask them to include the .htaccess and compress_css.php files with their plugin! Let’s start a “Compression Now!” Movement and encourage smarter development.

    Create a file called compress_css.php and put it in the css subfolder (the one you probably just created). Here’s what the file should contain:

<?php
ob_start ("ob_gzhandler");
header ("content-type: text/css; charset: UTF-8");
header ("cache-control: must-revalidate");
$offset = 60 * 60;
$expire = "Expires: " . gmdate ("D, d M Y H:i:s", time() + $offset) . " GMT";
header ($expire);
?>

    This does the same thing as we did with JavaScript, except the content type is ‘css’ instead of ‘javascript’, to serve css files properly. Create a .htaccess file and put it into the css subfolder. Then add the following into the .htaccess file:

# css compression
AddHandler application/x-httpd-php .css
php_value auto_prepend_file http://path/to/your/compress_css.php

    This pre-pends compress_css.php (from the root folder, where you placed it earlier) to each CSS file in the same folder, which will compress and cache the CSS files in the current folder.

    You’ll then have to manually edit the plugin’s PHP file(s) and ‘point’ it to the new location for the CSS file(s). All of the plugins I’ve seen so far have only one place where the CSS file location is defined. After that you should move the css file(s) into the subfolder. You’re done!

    You’ll need to repeat this process for every plugin or folder that has CSS you want to optimize.

  1. Create css subfolder (if needed)
  2. Create .htaccess file in css subfolder (and make sure compress_css.php path matches the path in .htaccess)
  3. Edit PHP file(s) to point to css subfolder
  4. Move css file(s) to subfolder

    The wp-admin/css folder is a perfect candidate to test out this technique, since it contains only CSS files. You won’t need to edit any PHP to practice on this folder.

    Check http://www.websiteoptimization.com/services/analyze/ again. Your .js AND .css files should now show as compressed. Excellent!

3. Compress PHP

    A lot of “WordPress speed” websites tell you to use mod_deflate to compress your server output. The problem is, what if your web host doesn’t allow it? mod_deflate uses more CPU, so you can see why some web hosts don’t want to enable it. But you can still compress your PHP output, uzing zlib. As a last resort, we can use the technique above. First you do want to check if it’s enabled.

    Your web host may have an option to check php version info, installed modules, etc. If not, you’ll need to do it by hand.

    Start with an empty text file and place the following:

<?php phpinfo(); ?>

    Save it as test.php, upload to your site and load it in your browser. Search the resulting page for the keyword “zlib” and look for “zlib.output_compression”. If it’s “On”, we’re in business. Place the following in your root .htaccess file:

# php compression
php_flag zlib.output_compression On
php_value zlib.output_compression_level number

where “number” is a number from 1 to 9. You’ll need to experiment to see what value works for your site.

    If you can’t use zlib, see below for how we can adapt the above technique for compressing PHP.

4. Compress HTML

    Create the following file in your root folder and call it compress_html.php:

<?php
ob_start ("ob_gzhandler");
header ("content-type: text/html; charset: UTF-8");
header ("cache-control: must-revalidate");
$offset = 60 * 60;
$expire = "Expires: " . gmdate ("D, d M Y H:i:s", time() + $offset) . " GMT";
header ($expire);
?>

    And put the following into your root .htaccess file:

# html compression
ForceType application/x-httpd-php
php_value auto_prepend_file http://path/to/your/compress_html.php

    As above, this passes all .htm and .html files through the PHP script, which compresses and caches it.

    If you want to include PHP files (for example, your web host doesn’t allow zlib compression), edit .htaccess and add the PHP file-type to the regex as follows:

Change

<FilesMatch "\.(htm|html)">

to

<FilesMatch "\.(htm|html|php)">

since the Content-Type for PHP is also text/html, this is a simple addition that makes a big difference and is so easy to do.

    If you check http://www.websiteoptimization.com/services/analyze/ again, you should see that ALL your files are now compressed. If any CSS files are uncompressed, go back and apply the CSS technique above on the given folder. If little to nothing is compressed, get a better website host! Contact me privately and I’ll send you a link to a good host (I can’t post the link on wordpress.com).

5. Use WP-Super Cache plugin

This plugin is a must for any WP site with even moderate traffic. I started using it after my website started getting throttled by my webhost for repeated hits. My goal was to limit the amount of duplicate requests (especially the database calls). If you do nothing else, this will lower the amount of database calls your site has to make, resulting in a faster site and better browsing experience.

Categories: Hacks Tags: , , , , , ,

Coming soon: Everything WordPress

January 4, 2010 Leave a comment

Welcome to my new blog. This site will feature articles on SEO, WordPress tips, tricks, and PHP hacks. Everything will be from a WordPress perspective, since that’s what I use for my sites and that is what I am most familiar with. The first “real” article will be about compressing your site to make it faster. We’ll review low-level methods for compressing PHP, HTML, CSS and JavaScript using PHP and .htaccess. Comments and questions are welcome, the more the merrier. Stay tuned!

Categories: WordPress Tags: , , , , ,