Basic SEO in MODX Revolution
In this post, we're going to take a look at five on-page SEO factors and how to make the most of them with MODx Revolution. Because MODx allows us complete control over our templates, markup, URLs, and allows us to create template variables to our hearts desire, it is perfect for creating optimized websites. I'm not going to focus too much on the purpose or content of each factor, as there are many other resources written by people far more knowledgeable than myself, but rather how to quickly and easily implement the basics in Revo.
What are on-page SEO factors?
SEO factors generally fall into two categories: on-page and off-page. On-page factors are things you can change within your website to make it more optimized for the search engine crawlers, and off-page factors are the things that aren't actually on your website, but do help move you up in the SERPs for example getting quality links from other websites.
Meta Tags
A few years ago, these were one of the most important on-page factors. These days, with the exception of the title tag, they're largely believed to be ignored by the crawlers (especially Google). However, having a well written description can improve your click through rate, which ultimately will improve your ranking and optimizing the <title> element is one of the simplest and most effective ways to improve your position.
To handle the meta tags in the CMS, we create three TVs named metaTitle, metaDescription and metaKeywords. It is possible to use some of the built in modResource fields such as Description, Title, Longtitle or Summary (introtext), but we found it was much easier for the end user to have all these settings in one place, and it also allows you to set defaults (highly recommended) and character limits on the TVs if you wish to.

Now we just need to place the following in the <head> section of our templates.
[[*metaTitle]]
Friendly URLs
Each resource in MODx can have a fully customized alias or URL, making it extremely easy for us to follow SEO best practices for URLs. First of all, you can configure all the Friendly URL settings in System Settings by selecting the Friendly URL area. To enable friendly URLs, make sure the "Use Friendly URLs" and "Use Friendly Aliases" settings are set to Yes. It's also a good idea to enable "Use Friendly Alias Path", this will follow your site structure so that child resources use /parent/child.html style URLs (as opposed to child.html being available on the root of the website). You may also want to set automatically generate alias, which will convert your Page Title to an alias unless the alias is otherwise specified. Your settings should resemble the below.

View the MODx Guide to Using Friendly URLs for more info.
In terms of best practices, stick to under five 5 words in a URL (if you must have more than five, try to get your primary target keywords in the first five), dashes (hyphens) are better than underscores, URLs are case sensitive so it's always best to stick to a lower case URL and MODx will convert all aliases to lower case for you.
Worried about your URLs looking "spammy"? SEOmoz has a very useful tool that will evaluate a URL and screen for spam words, hyphens, domain length, digits etc and return you a score. SEOmoz URL Spam Detection Algorithm
Canonical Element
Over the last few years there's been a lot of fuss in the world of webmasters surrounding a so called "duplicate content penalty". I'm not going to get into that in this post, as it's largely irrelevant and quite possibly doesn't even exist. The outcome is that the search engines provided an element that allows us to specify the preferred URL for accessing a page. This is particularly important when using a system such as MODx, where a page can be accessed by multiple URLs.
For example:
http://www.yourdomain.com/home.html,
http://www.yourdomain.com/index.php?id=1,
http://www.yourdomain.com/1
and even http://yourdomain.com/1/
all point to the same resource, but are all seen as different URLs. Now we can tell Google that we prefer our pretty, keyword rich, friendly URLs (http://www.yourdomain.com/home.html) and that's the one we want to see in the result pages.
Lets take a look at the element.
Now lets take a look at it in a MODx template or chunk.
Simply place this in the <head> section of your templates, and that's all there is to it! The link tag will dynamically generate the nice friendly URL for our page, and place it in the canonical element. While the canonical element does support relative URLs, I like to use &scheme=`full` (this will generate the full URL including your domain name) just to be safe. You can see an example of this in action by viewing the source of this page.
One final thing to note here, is that http://www.yourdomain.com/home.html and http://yourdomain.com/home.html can also be perceived as different pages. It's best to choose which you would prefer, www. or no www. and redirect anything else with a 301 (permanent) redirect. Again, the MODx team have made this very easy for us, but we will have to get our hands dirty and edit the .htaccess file.
If you view your default .htaccess file, you should be able to see the below code right under "RewriteBase /"
# Rewrite www.domain.com -> domain.com -- used with SEO Strict URLs plugin
#RewriteCond %{HTTP_HOST} .
#RewriteCond %{HTTP_HOST} !^example-domain-please-change\.com [NC]
#RewriteRule (.*) http://example-domain-please-change.com/$1 [R=301,L]
#
# or for the opposite domain.com -> www.domain.com use the following
# DO NOT USE BOTH
#
#RewriteCond %{HTTP_HOST} .
#RewriteCond %{HTTP_HOST} !^www\.example-domain-please-change\.com [NC]
#RewriteRule (.*) http://www.example-domain-please-change.com/$1 [R=301,L]
As you can see, MODx have provided us some rewrite rules to handle this problem. All we need to do is edit the domain name, and remove the #s in front of the condition that we want to use. For example, if you would like to forward http://butter.com.hk/ to http://www.butter.com.hk/, you would have to update the domain and remove the hashes from the second block as below.
# Rewrite www.domain.com -> domain.com -- used with SEO Strict URLs plugin
#RewriteCond %{HTTP_HOST} .
#RewriteCond %{HTTP_HOST} !^example-domain-please-change\.com [NC]
#RewriteRule (.*) http://example-domain-please-change.com/$1 [R=301,L]
#
# or for the opposite domain.com -> www.domain.com use the following
# DO NOT USE BOTH
#
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.butter\.com\.hk [NC]
RewriteRule (.*) http://www.butter.com.hk/$1 [R=301,L]
NOTE It is very important that you do not remove the hashes from both blocks, as this will cause a 500 Error.
If you would like to read about the duplicate content penalty, here's an old post from the Google Webmaster Central blog
Google Sitemap Snippet
I found a quote from Google's Conversion University that I think explains the sitemaps purpose better than I ever could.
Let's start off with a quick look at what Google Sitemaps is – and isn't. Google Sitemaps is a service that allows you to submit ALL of your pages to the Google index. It's particularly useful for making sure that dynamically generated URLs or pages that are not adequately linked to on your site get indexed. By submitting your URLs in a Sitemap, you help Google's web crawler do a more complete and efficient job of crawling your site.
This sitemap is an XML file that lives at www.yourdomain.com/sitemap.xml. Luckily for us, Shaun McCormack (aka splittingred) has put together a very simple snippet that will generate and maintain this for us. All we need to do is download the snippet from package management, create a new resource on your site root with a Blank (empty) template, you can set the page title to anything, but it's best to set the alias as sitemap. Set the Content Type to XML under page settings, and call the snippet with , and that's all there is to it!
There's heaps of configuration options for the Google Sitemap snippet, you can view more on the MODx documentation.
Once you have this URL up and running, it's best to submit your sitemap to Google using the Google Webmaster Tools.
Content
The most important thing to remember, is you should be writing your content for your users and not the search engines. Once upon a time "keyword stuffing" was an effective technique to increase your ranking, today it's generally counter productive and makes your site look "spammy" to both the user and the search engine crawlers. It's a far more effective long term strategy to focus on having high quality, unique content that will engage your users, and keep them browsing your site. In saying that, having keyword phrases in your H1, and to a lesser extent h5 tags is largely believed to increase your rankings. There's a lot of debate over how much this will effect your rankings, but it is widely agreed that it does have some effect.
Depending on how your template is structured, you may need to enter your H1 tag into your page content in the CMS. We generally place an H1 right before any content that contains the Basic SEO in MODX Revolution template variable. This allows a user to specify the first (arguably the most effective) H1 on the page with a keyword rich heading.
Another tip is to make sure to include keywords in your internal site links. The search engines use the "anchor text" or the words in a link as a factor in determining what the page you're linking to is likely to be about. For example if your anchor text contains the words "MODx Tutorials", the search engine will assume you're probably linking to a page about MODx Tutorials. Something like Click here for MODx Tutorials, would be much better written as Click here for MODx Tutorials. This also applies to links you have coming in from other sites. If you use the above technique and set keyword rich Page Titles on your document, these Page Titles will also be used for the anchor text when using a snippet such as Wayfinder or getResources to build your site navigation. If the Page Title is too long, or doesn't quite suit you can always override it with the Menu Title field.
Further Reading
Here's a list of some of my favorite resources for learning about SEO and the behavior of Search Engines.
- SEOmoz
SEOmoz offers excellent lessons and tools for SEO. They also have an awesome blog for keeping up to date with the world of SEO. - Matt Cutts' Blog
Matt Cutts is the head of Google's Webspam team, and has a great blog about Google and SEO. - Affilorama
While Affilorama is targeted at affiliate marketers, the free lessons on SEO are perfect for beginners, and can be applied to any kind of website.
- Monday, 22 August 2011
- 6 comments

martin:
Feb 26, 2012 at 09:30 PM
there's a typo in your code - it should have the quesitonmark, right?
[[~[[*id]]? &scheme=`full`]]
Greg Babula:
Mar 08, 2012 at 10:12 PM
@Martin - that's absolutely right, without the question mark it only spits out the page name without the full URL
website design:
Apr 11, 2012 at 10:02 AM
here's a typo in your code - it should have the quesitonmark, right?
steel bands:
Jun 17, 2012 at 01:22 PM
We have now started using Modx revo and it is easy and well presented, there are also videos for the cms on YouTube. Highly recommended!
Mark:
Oct 18, 2012 at 07:30 AM
Hi,
I just rewrote mine to remove the www as follows
RewriteCond %{HTTP_HOST} ^www.mydomain.com.au [NC]
RewriteRule ^(.*)$ http://mydomain.com.au/$1 [L,R=301]
While that works, it's obviously a bit different than the default modx rewrite rules.
I was just wondering if there is anything problematic or missing from the way I've done it.
Lee Noel:
May 21, 2013 at 03:28 PM
I am very much thankful towards the SEO HK. By reading your blog, I have found out the resolution and I think the proper application of SEO will help me in getting the rank of my website.