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? If you want to know, 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.)
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, starting 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. Fortunately, you can define a nicer, alternate path – what's called an "alias" – when creating a content item.
(A note: Drupal inconsistently uses the word "path" to sometimes 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 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 setting', 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
There are two tabs:
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.
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.
Automated alias creation
How would you like your site to generate an alias for you automatically whenever you create new content? It can be a very useful thing, and is handled by a function called Pathauto.
If your site has Pathauto enabled, you'll find an administration form here:
Navigation » Administer » Site configuration » Pathauto
There are a lot of settings, and an overview will have to wait for later. For now, you should be able to work things out through the instructions on the form.
Finding a path
It's handy that you can set an alias for any new content you create, but how do you find the path for any 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 the 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 » Comment
Getting a Term's path
A link to a whole Term can be a very useful thing. Even better, Drupal automatically creates a path for each 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 » Categories
As discussed in Terms, Vocabularies, and Categories: "Tagging" Your Content, that's the list of Vocabularies, or groups 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 Categories 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 your menu item's path.













Post new comment