Ok so here is the roadtrip to optimal SEO settings and best practice for Drupal, going from setting the URLs to be search engine friendly, creating URL aliases, creating default templated URL aliases, setting up redirects from older URL aliases. Setting up Page Titles, Meta Tags and Canonical links – lets get started…
Off the bat the URL default strings in Drupal are dynamic and have search engine unfriendliness > ?q=
To switch these to clean URLs, there is a setting in core Drupal that you can enable, at Admin>Configuration>Search and metadata >Clean URLs, just check that on.
This results in a cleaner SEO friendly format:
URL Path Aliases Basic
Ok now our URLs look friendly but not very descriptive, you can get all your nodes indexed in the search engine but we need some better aliases than one ‘node’ word and number – there is an option to manually add an alias name to the node in the URL field at the bottom of a content template.
This results in an overall better result:
You can manage the alias paths or even add them at Home » Administration » Configuration » Search and metadata » URL aliases
URL Path Aliases Advanced
These modules work together, with pathauto functioning to alias the path of a formed URL to the actual node in Drupal, how it forms the URL in terms of text is from a pattern as assisted by token, which will typically be the title of the content page or article or from a number of variables.
So it would do the same thing as the basic alias by aliasing for example:
http://mydomain.com/hello-i-am-an-alias to http://mydomain.com/node/3
But the advanced part of pathauto is that it enables a ‘pattern’ tab back in the URL aliases section which can be used to set default URLs for content without you having to manually enter in the URL based on a pattern which you control and that also you can override manually.
So get to it at /admin/config/search/path/patterns.
It contains configurations for each content type you have as well as taxonomy and user nodes, you don’t have to fill in each content type you can just fill in the default path for all content types which will be applied to all content types if the other content types are empty.
Note that your taxonomy tags and user account pages are also separate nodes which are indexed by the search engines and delivered in search results, so makes sense to put something worthwhile for these too.
So basically you set the pattern in each type by just click inserting or copying the Replacement Patterns (which are the tokens or variables), in what you want to be the default pattern of your URL, normally most sites will set the node title [node:title] as the URL and perhaps add in another variable before or after such as a date you can just daisy chain these variables after one another and if you decide to do that you should put in a hyphen ‘-‘ between variables otherwise they will run together, the defaults are pretty good:
So now each time a new content is created the variables from the patterns above will be used as the URL alias for the content, this is controlled by the ‘URL path setting’ at the bottom of the created new content, if the ‘Generate automatic URL alias’ is clicked the pattern will be used. (You can still uncheck it and manually add in the URL alias).
One of the dangerous sides to the automatic approach is that if you change the title of the content in the title field the URL will also change, which means that the previous URL will generate a 404 error which is not so cool, this has caught me out quite a few times as I stare at my 404s in my analytics software.
There are a couple of solutions to this either just uncheck ‘Generate automatic URL alias’ after the content is published or before you change the title. The issue sometimes is that you don’t always remember to do that – this is where the redirect module comes to the rescue.
Redirect URL Aliases
The redirect module when installed is great, it will keep track of all the URL alias changes and redirect any incorrect or older incoming URL alias requests to the updated and current ones. So if you have your content to generate automatic aliases and you change the title which generates a new URL, redirect will remember the old URL and forward to the new without you having to remember.
You’ll find the redirect data also down the bottom of the content page.
If you end up with too many redirections on a node the URL may not get resolved, just do some deletions from the redirects. This is a great module but beware that it is always preferable to stay with the original URL in particular if you have built up some SEO weight with it and also social media presence, for instance if you have a bunch of Facebook likes and you change URL – you will lose all the likes and have to start over.
Getting all Right in the Head
WIth the URL aliases under control, time to concentrate in the head section, what controls the page title tag in the head of the document?
By default Drupal uses the node title and the site name and site slogan separated by pipe symbols ‘|’ – the site name and slogan are defined at admin/config/system/site-information. To gain better better control use the Meta Tags module which now encompasses page title ability, previously another module was needed; page_title.
You need to add in meta tags in the head section of your Drupal pages for title, description, keywords, facebook opengraph and dublin core settings – this is all done by the metatag module. Install the module and you can edit global configurations at /admin/config/search/metatags same pattern emerging here, set the global configuration for front page, nodes, taxonomy and user content. Click on the overide to get into the details.
You can edit the content node type directly per each piece of content you create.
This without a doubt a powerhouse of a module – as well as the standard tags you can also set the Open Graph and Dublin Core as well as set individual index and follow settings in the Advanced Tab
That’s pretty much it, just one thing to tidy up which is the possibilty of duplicate content and canonical URLs. Canonical URLs are a meta tag setting displayed in the head as:
<link rel="canonical" href="/myurlalias" />
This is how it is displayed as the default in Drupal, as a relative URL, but after you add the metatag module it by default will display the URL as an absolute URL (see last field in the above pic) and below is how it is rendered:
<link rel="canonical" href="http://mydomain/myurlalias" />
This is considered better practice and what it does is tell the search engines which URL it should index and recognise if you need to add the same content on 2 or more different nodes on the same domain. Using the canonical tag tells the search engine – yes I am using duplicate content but don’t penalise me, here is the right URL to index.
One last issue remains the node is still accessible as a node—
Which means that the search engines still are indexing the same content twice once as the node URL and the other as the alias URL.
A module to the rescue Global Redirect (globalredirect), install the module and enable, configure it from admin/config/system/globalredirect
There are quite a few settings here, check the documentation with the module to set to what meets your needs, the defaults are pretty good and it prevents the node URL from appearing, instead redirecting to the URL alias, there is no need to add the canonical link as this is already added if you have used the metatag module.
Thats pretty much it – now your URLs should be tamed and are a good base for your SEO settings.