To give our users cool looking urls, as well as optimise the chance of their blogs being found on google, we've made some significant changes to the Core functionality of Drupal. Since the Drupal software and accompanying Modules were completely free, it's only right that we share with you how we did this, so that others can benefit from this amazing software. A big thanks to everyone who contributed at
Drupal.org, as well as the
Pathauto module which we will use in this tutorial.
What, how, and why
Ok so you've got a Drupal 6.x website, and now you want to give each user their own URL. For example, you might want mysite.com/user to point to user's blog, and all of user's articles to go into mysite.com/user/my-day-at-work. Ofcouse if you wanted to modify the steps in this tutorial to, for example, let mysite.com/blogs/user point to user's blog (or evenuser's profile) it will be very simple to do this, and I'll point out where you can make your own modifications if you want.
This tutorial uses the
Pathauto module, which at the time of writing was at version 6.x-1.1. In this tutorial I will show you how to give each user their own directory for their content, as well as a more effectively structured forum system. Specifically I will tell you how to do the following:
Why have I done it this way? Well it's part Search Engine Optimization and part personal preference. The forum topic names can get quite large, but forum topics are often quite badly designed by users (because little effort is given to SEO by the authors), so having a precise and descriptive (albeit long) url can help get the article indexed more effectively by Google. As I go through this tutorial, I will do my best to explain where you can make you can do things differently, so no matter how you want to structure your URLs this tutorial should be of some help to you. Regardless of how you do it, the most important thing is that you decide how you want to structure your URLs before you start this tutorial. It's a very bad idea to go changing links on your website once it's up and running, google will have your head on a platter.
I am assuming that you are logged in with administrative privileges, so please do this before starting to avoid some confusion!
Part 1: Enabling Clean Urls
The first step is to enable clean URLs if you haven't already done so. I won't reinvent the wheel, Drupal.org have published an excellent article on this so before you go any further if you haven't enabled clean URLs check out the
Clean URLs tutorial. Ok I'm not sure I needed to make an entire section for that... Oh well, time to move on.
Part 2: Install and Enable the required modules
Download the latest Pathauto Module from the
Pathauto Drupal Module site. In order for Pathauto to work will also need the
Token Module, so download this as well. To install the modules simply copy each of the extracted folders into the
mysite.com/sites/all/modules directory. You now need to enable them, as well as the core module called
path, to do this go to Administer->Site Building->Modules and look for the Token and Path modules. Tick the box next to it and hit Save Configuration. Now do the same for the Pathauto module.
I am making the hasty assumption that any new version of Pathauto will work in a similar fashion. If it does not, please don't eat me, just let me know what was different by commenting on this article and I will update it as soon as I can. OK here goes
Part 3: Pathauto General Settings
To configure Pathauto go to Administer->Site Building->URL Aliases->Automated Alias Settings (or if you are displaying by module use Administer->Path->URL Aliases->Automated Alias Settings). You can now begin setting up the module to automatically give aliases to user created content, and should see a page with a list of URL aliases that have already been created (if you just completed step 1 of this tutorial the list will be empty). Bottleweb.org is currently set up to only use Blog Pages, Forum Pages, and Comments. Therefore I will only go over attributing URL alias patterns for those types of content. Click the Automated alias settings button to begin modifying the pathauto module settings.
Click "General Settings" to expand that tab if you cannot already see its contents. We can now modify some of the General Pathauto settings. Google will typically recognise the dash character as representing a space in a URL, so it's a good idea to set the Seperator character as the dash (-). Forcing the characters to lowercase in the Character case option is basically a matter of preference, I would recommend lowercasing all URLs. It is very important that you set the maximum alias length to nothing greater than 100. This is because the mysql database entry for the url has a default maximum length of 128, and very often extra characters are appended to the url (such as /feed for rss feeds). If that didn't make any sense to you don't worry, just leave it at 100!
Depending on how many pages you already have in your web page you may want to increase the Maximum number of objects to alias in a bulk update, IF you decided to update existing entries (we'll get to that in a moment). Increasing this value will allow retrospective changes to be made in one go for larger drupal site. If however this number is too large it will cause timeouts. If you are finding that your settings are taking too long to apply, you may need to reduce this number (for us it worked fine to go in sets of 1000) and apply the settings several times. The next settings is the Update Action field.
The option you select here depends largely on a combination of your website history and your own attitude. If your website has been around for a while and many of the blogs and forum entries are already linked from external websites, I would strongly recommend selecting the Do Nothing option. If your website is relatively new, and you don't expect many websites to already have links to your content, then by all means select the Create New Alias. Delete the old Alias. I would not recommend selecting Create a new alias. Leave the existing alias functioning. because it will create what search engines will recognise as duplicate content. This is never a good idea, so don't select this option unless you really know what you are doing.
At the bottom of the General Settings tab, there is a texbox full of strings you can remove. It is a good idea to keep this list, and increase it if possible. Keep in mind that the purpose of URL aliasing is to make the URL as concise and descriptive as possible to both humans and search engine bots. If I make a page called The Cat is Large and Fat, then it would be cumbersome and not in the least beneficial to also name the URL ../the-cat-is-large-and-fat. The url ../cat-large-fat contains the same important keywords, and is much shorter. Common words such as "and, if, then, or, a, the" are not going to be considered in the least bit interesting or unique by a search engine, and article titles rarely contain complex grammatical functions that necessitate these words to make the meaning clear.
Part 4: Punctuation Settings
The way I see it you have 2 options here: replace punctuation with a dash, or just delete it. I personally think that the best option is to simply remove the quotation marks and single quotes, and replace the rest with the separator. Whatever you decide, please don't let it be No Action. Keeping punctuation in your URL is never a good idea.
Part 5: Blog Path Settings
This section will define where the user Blogs are located. You will notice that if you click on the Replacement Patterns Button you will see a list of tags you can use to generate the URL dynamically.
If you know of a list where the terminology in these lists is explained in greater detail please let me know so I can link it here
For Bottleweb, we wanted each user's blog to exist in
www.bottleweb.org/user, so we used
[user-raw] as the pattern. It is important that you always use the "raw" version of the tag. Pathauto will issue you with a warning if you don't do this anyway. Feel free to use combinations of different tags or even your own text. For example, if you want to have the blog at
mysite.com/blogs/username you would use
blogs/[user-raw] as the pattern.
The Bulk generate aliases for blogs that are not aliased option will apply the setting for this particular type of page (blogs in this case) to all existing content of that type based on the Update Action that we specified earlier. So if you find that no pages are updated when you have selected this option, it's probably because you selected Do nothing. Leave the old Alias intact as your Update Action. The Internal feed alias text (leave blank to disable) setting simply specifies where you want the RSS feed for that type of content to be aliased. For example, if your blog is at http://www.bottleweb.org/administrator and you want your feed to be located at http://www.bottleweb.org/administrator/feed then you would simply enter <em>feed</em> into this field. The Internal Feed Alias Text and Bulk Generates Aliases options exists for every type of page, so think carefully about how you want to apply your settings for each type of content.
Part 6: Node, Taxonomy, User-Tracker, User Path and Forum Path Settings
Nodes are the Drupal version of pages, so when setting up the URL settings for nodes, you are actually setting the URL for the individual pages of all kinds (Blog article, Book, Page, Forum Topic, etc.). Since Bottleweb only uses two kinds of pages - Blogs and Forum Topics - we only needed to specify the 2 patterns. You may want to do more, this is entirely up to you.
For this tutorial we wanted to place all blog content in the subdirectory of the author, so if
Administrator wrote an article called
Unique URLs for Drupal site members on bottleweb.org, the article would be aliased to
http://www.bottleweb.org/administrator/unique-urls-drupal-site-members (remember that simple strings, in this case
for, are removed). To do this we used
[author-name-raw]/[title-raw] for
Default Path Pattern. To place all forums in the subdirectory of their containers, and all forum topics into the subdirectory of their forum, we used
[termpath-raw]/[title-raw] for
Pattern for all Forum Topic Paths. All other fields were left blank and therefore adopted the default, which is to alias the content into the subdirectory of the Author.
We do not use Taxonomy terms so that section was left as the default.
We wanted the user tracker to be in the
http://www.bottleweb.org/username/track so we used the pattern
[user-raw]/track in the
Pattern for user-tracker page paths field. To alias the user's profile to be in
http://www.bottleweb.org/username/profile we used the pattern
[user-raw]/profile in the
Pattern for User Account page paths field.
Finally, to alias each forum to the directory of its container, we used the pattern [catpath-raw] in the Pattern for Forums and forum containers field.
Thanks for Reading!
Well I hope this tutorial has been of some help to you. In return for the work I've put into writing this, please take the time to comment. This tutorial is a work in progress so if there is something you would like to see explained more clearly, or if you have found a mistake, feel free to let me know and I will update it.
Catherine White
Bottleweb.org
Nested taxonomy terms
how to create your own menu
Hello Catherine
I've got a drupal site and I am trying to create my own menus.
The problem I am having is how to create content for a content type. Every time I create something I cant access it again in my menu.
Can you help?
I am using pathauto at the moment but I am uncertain what path types to create for my nodes?
Chris
hi chris
Moved this to a forum: http://www.bottleweb.org/internet/drupal-development/chris-question-1
http://bottleweb.org/administrator
Post new comment