Have you ever needed to automatically create a URL with a structure like the one below?
http://mysite.com/site-section/sub-section/sub-sub-section/node-title
There are a couple ways to accomplish this. The first step is to install the Pathauto and Tokens modules. You might need a couple more depending on which strategy you choose to use. Below are several strategies you can use to accomplish this requirement.
Taxonomy Term
If you only have one level to your URL structure, you can use a vocabulary.
- Start by creating a vocabulary called Section (or anything you want).
- Make sure the Section vocabulary is weighted to always be the first vocabulary that appears on your add/node interface.
- Add terms that represent your site sections.
- Go to site building>URL aliases>automated alias settings
- Configure the node path settings:
[term-raw]/[title-raw] - If the vocabulary is not required and not selected, the path defaults to [title-raw]
Text Fields
With the CCK textfield option, you can make a series of text select fields. Create a field for each section / sub-section level of your site.
- Start by installing CCK module and enable the text field.
- Go to content management>content types>edit page (or whatever CT you want to add the fields).
- Create a field for each section and sub-section you need and insert the applicable section and sub-section text you need.
- Go to site building>URL aliases>automated alias settings
- Configure the node path settings something link this three levels:
[field_section-raw]/[field_subsectionone-raw]/[field_subsectiontwo-raw]/[title-raw]. - If the fields are not required, the path defaults to [title-raw] if nothing is selected.
Content Taxonomy Field
This combines the first option with the second option. Instead of using the text field to create a select list, you use the Content Taxonomy field module and make your list by populating a series of vocabularies (section, sub-section-one, etc.), one for each level you need and for each field you create.
The path would look similar to the text field sample above:
[field_section-term-raw]/[field_subsectionone-term-raw]/[field_subsectiontwo-term-raw]/[title-raw]
Hard Code
Don't cringe! There are times when it is more convenient to simply hard code the terms you want for the path. For example, let's say you have a content type for each section of your site (news, events, projects). You could set each content type to have it's own path.
- news/[title-raw]
- events/[title-raw]
- projects/[title-raw]
Combination of the Above
Like with a lot of features in Drupal, you can use a combination of the above. For example:
news/[term-raw]/[field_sitesection-raw]/[field_subsection-term-raw]/[title-raw]
Conclusion
You have other options with Pathauto of course. For example, you can use [term-raw]/[book-raw]/[title-raw] when you want your book pages to appear with the book's first page. The challenge comes when you need custom site sections. Hopefully this gives you some options.


Order yours now.
Hello Cindy,
I am still new to drupal and does not have sufficient knowledge about the api. I was hoping you could make a video tutorial on youtube or anywhere else on how to do this. A sample site too could help. That would be so great!
Thanks
I suppose I could make a short video. I will put it on my list of things to do.
Some More Tips:
The primary taxonomy (VID 1) is "location", a multi-level taxonomy, which is a prerequisite of business directory nodes, events, groups, and userprofiles.
Then there is business category (VID 2), multi-level as well, also pre requisite of business directory nodes.
There is also "group type" (VID 3), "event type" (VID 4) prerequisites of groups and events respectively.
Now that we have a clear picture of the site structure, the problem is how do I configure SEO friendly pathautos.
I have the following landing pages, for the site sub sections, thanks to panels and views.
/directory
/community
/events
I was thinking of 2 possible url aliases. First one being short and precise, containing the site sub-section/nodetype/title. Or the second one which is more descriptive containing site sub-section/nodetype/location-taxonomy/business-type-taxonomy/title
Formula 1 lotto system review
/directory/nodetype/[title]
or
/directory/nodetype/[location-raw-cat]/business-type-raw-cat/title
/community/[nodetype/[title]
or
/community/nodetype/location-raw-cat/title
/events/[title]
or
/events/location/event-type/date/title
Then there is the problem of users pathauto variables. I have the following node types, in addition to the default "user" variable, that link to a user's page
userprofile
usernode
bio
What will be the most ideal, SEO friendly, pathauto settings for these? Will they be treated as repeated content by search engines?
I would love the alias to user profiles to be something like
/community/people/username
I hope I have presented my case in a clear and precise way, and hope to get some
Aliases can be used to convey the IA of a site, keywords that represent the content of the site, or a combination of the two. What are you trying to accomplish?
If SEO is your objective, then your objective is to improve the visibility of your site. Sites show up when someone searches. Who is your audience and what keywords will they use when searching? Of those keywords, which ones are associated with what your site offers? When your users do a search, will it include "location" or "events"?
Side note, when you choose a pattern, remember that it needs to produce a unique alias each time so /community/people/username won't work but /community/people/username/title-of-node will work.
I have 4 pages on this topic in my new book so I am having a hard time finding a way to convey that information is a short reply. Page 186 starts Path Structures. Although I would love for you to buy the book, you can read these pages on Amazon if you search inside the book.