Content Paths and URLs

How do people get from one page on your site to another? Links, links, links!

But what is a link? It's just an instruction for the browser to jump from the current page address to a new page address.

You can create links to any page whose address you know. So how to you find, or create, the address for a page? Here's your guide. (And if you already know the address for your target page, and are ready to create a link to it, jump ahead to Creating Links.)

One note: Much of the following discussion pertains to Drupal sites using two common modules (Path and Pathauto). That most likely includes your site as well, but if the below doesn't seem to apply, ask your main administrator about the setup of the site.  

Path and URLs

Every node you create in Drupal automatically gets a path – an internal "address" that identifies it. Drupal automatically gives these paths names that aren't too pretty, such as taxonomy/term/7 or node/53.

A URL is the whole address, beginning with your site domain, that a browser uses to reach a page. The above node with path node/53 could be reached by visitors at www.drupalace.com/node/53, for example.

Prettier paths: aliases

The above node/53 is an ugly path that creates an ugly URL. There's nothing technically wrong with that at all, but many people like nicer-looking addresses. (Supposedly, so do the search engines.) Fortunately, you can define a nicer, alternate path – what's called an "alias" – when creating a node.

(A note: Drupal documentation sometimes uses the word "path" to mean the content's address in general, and sometimes to mean an alias. I'll use "path" to mean the internal address of a content item, and "alias" to mean an alternate path. These are pretty standard usages, so no capitalization is needed.)

An example of an alias: If your 'Corporate Vision' page has the path node/53, you can also give the page an alias such as vision. The page can then be reached at the URL <your site domain>/node/53, or at the alternate URL that uses the alias, <your site domain>/vision.

Setting an alias

As described under Create a Page, you can easily create an alias when creating or editing a node. Look for the field 'URL path settings', and type in an alias. Stick to regular letters, numbers, hyphens (-) and underscores (_) in your alias; avoid other characters, including spaces.

Managing aliases

If you want to change a node's alias, just edit the node to do so, as above.

You can't give the node more than one alias that way, though. If you'd like to do that, and otherwise manage aliases in bulk, head here:

Navigation » Administer » Site building » URL aliases

List

Pretty simple: a list of aliases, followed by the "real" path that Drupal created (like node/13), followed by options for editing or deleting the alias. There's also a filter provided for quickly finding the aliases you're looking for.

Add alias

Here's where you create an alias. Enter the Drupal-created path into the first field, and your desired alias in the second. Follow the rules under Setting an alias above.

Delete aliases (Drupal 6)

Here you'll find checkboxes for mass deletion of large groups of aliases.

Automated alias settings (Drupal 6)

This is a great tool if you want to let Drupal create aliases for you, based on rules you set up. See discussion below.

Automated alias creation

How would you like your site to generate an alias for you automatically whenever you create new content? That can be a very useful thing, and a great way to make sure aliases for multiple nodes use a consistent format – an especially important concern if you have multiple users creating content. That is, you don't want one day's news article to have the alias news/12/24/Christmas_Eve_Events, the next day's to look like news/1225/Xmas-dinner-party, and the next day's to appear as news_story/Dec-26-the-hangover. Let Drupal automate those aliases, and they'll hew to a consistent format.

Under Drupal 6, the administration tools appear under the "Automated alias settings" tab of the "URL aliases" administration form, as noted above. Under Drupal 5, you'll find the form elsewhere:

Navigation » Administer » Site configuration » Pathauto

There are a lot of settings, and an overview will have to wait for later. Fortunately, the form's instructions are fairly self-explanatory and you should be able to work things out.

Finding a path

It's handy that you can set an alias for any new content you create, but how do you find the existing path or alias for existing content?

Check the browser's address bar

This is the most obvious method: open the page you're interested in, and check its URL in your browser's address bar. The part of the address remaining after <your domain name>/ is the page's path. Copy or otherwise make note of it, and you're ready to use it in links.

Check master lists

Your administration forms contain a number of "master lists" of content and paths. Once you're at any of the lists below, clicking on the item of interest, or just "mousing over" it and seeing the URL that appears in your browser's status bar, will let you know the item's path.

Master list of all content

Navigation » Administer » Content management » Content 

Master list of all aliases

Navigation » Administer » Site building » URL aliases

Master list of all comments

Navigation » Administer » Content management » Comments

Getting a Term's path

A link to a whole Term can be a very useful thing. Drupal automatically creates a path for each Term – which, more specifically, means a path that tells Drupal to create a page listing all the content tagged with that Term.

You can't just use the Term name, like 'product', as the path; you need to use the path that Drupal gave the Term. Unfortunately, a little digging is required. Here's how to do it:

Navigation » Administer » Content management » Taxonomy

(In Drupal 5, that last part is "Categories", not "Taxonomy".) 

As discussed in Terms, Vocabularies, and Taxonomy: "Tagging" Your Content, that's the list of Vocabularies, each of which is a collection of Terms. Click 'list terms' for the Vocabulary containing the Term you want. The list of Terms will appear. Click or "mouse over" the Term you want; you'll see the the URL containing the Term's path.

Example: You want a menu item to link to the Term 'technology', listing all nodes tagged with that. Go to the Taxonomy form, as above, to see your Vocabularies. There's one named 'Content Topic', which contains the Term you want; click 'list terms' for that.

There, on the list of Terms, is 'technology'. Click it. It should return the page we're looking for, listing all 'technology'-tagged nodes. Note its URL, which may be something like <your site domain>/taxonomy/term/12. The path taxonomy/term/12 is what you can use as the path in menu items or other links.

Comments

Nollen's picture

I ACTUALLY appeared to be happy to discover this web-site. I want to thanks for your time for this excellent learn!! I absolutely taking advantage of each little bit of it and I had you saved as a favorite to check out fresh items you text.
Can I just say nice to read a relief to find anyone who actually understands just what they may be talking about on the internet. You certainly discover how to take a problem to light and enable it to be vital. More people need to learn this and know this section of the story. I cannot believe you're not very popular because you definitely have the gift.
good blog post, i clearly enjoy this page, keep it.

newbie drupal admin's picture

drupal says like: <my site address>?q=admin/structure/taxonomy/<taxonomy name>.

So it cannot accessed by viewer / anonymous user. So how to know the path?

newbie drupal admin's picture

drupal says like: <my site address>?q=admin/structure/taxonomy/<taxonomy name>.

So it cannot accessed by viewer / anonymous user. So how to know the path?

tigita's picture

Question?

I need to figure out how to create a link to content that I dont want displayed in a table.  Huh?  e.g.

 

My content

This is my content that I don't want to show  like this but want linked to above content. 

 

 

Add new comment