PDA

View Full Version : Drupal blogging (Decent URL's)


Stryder
07-23-2008, 07:41 PM
One of the main problems with Drupal out of the box is that it's URL's aren't meant for either SEO (Search Engine Optimization) or for being rememberable or understandable at a glance.

To deal with this problem there is a standard solution of "re-aliasing" however this can take time by hand and is why most would choose to use Pathauto (http://drupal.org/project/pathauto). The problem for most people though is they don't necessarily know how to rig up the configuration to get the right type of URL's.

So the following is a very brief an comprehensive look on how to get Date and title laden URL's for use with drupal's internal blog system.

I'm just going to show a few images that I screen captured from my settings:
http://www.chatsoba.com/documents/drupal_pathauto/blog.jpg
This is just the Blog path settings, it's what is used from the main drupal page and links to a user's Blog index. You'll notice it says blogs/[user-raw]/ this is because you don't want to use blog as an alias for the first folder or it gets confused with the already implimented system, so you have use blogs. The [User-raw] entry will return what the users name is, however it will be sanitised through settings higher up the Pathauto admin page.

http://www.chatsoba.com/documents/drupal_pathauto/forum.jpg

Although I was just going to show date info for blog URL's, I've decided to throw in this forum easteregg. Be warned if you use Categories they will cause a different path from Post URL's which are going to be defined in the next image. All I can suggest is either to drop the categories altogether like I did or work out how to add them on the next image. Also don't call a forum or category something like "feedback/suggestions", You can use a hyphen "-" but most other characters are removed, except for this one which would signify another tier in a folder structure.

http://www.chatsoba.com/documents/drupal_pathauto/node.jpg
This is where you do the magic with your Date information. It took me a while to find it and work out how to use it and as you can see I still have a few entries left to play with.

The /node/[nid] entry is the pattern that's looked for when changing
The /blogs/[author-name-raw]/[dd]/[mm]/[yyyy]/[title-raw] basically is first made to follow the already create blogs/username convention set further up. However we've now added the Day, Month and Year plus a "raw" title. This is basically the same as the title used in a blogs entry creation however it has some words stripped from it prior to use. (It's useful to identify what the entry is as well as adding to Search Engine Optimization)
The /forums/[term-raw]/[title-raw] entry is again created to attempt to fit with what was previously set for forums. (However if you decided to use Categories, you will require adding the Category token after forums anf before [term-raw])

http://www.chatsoba.com/documents/drupal_pathauto/outcome.jpg
The outcome of these entries should appear in your Aliases menu ("site builting - URL Aliases")
You can see "feed" mentioned here, I didn't alter any of the Feed entries in the settings that you would have seen. They should work fine without editing.