URL structure
Drupal uses a URL alias system. There are two ways to access each node (page, space, device, etc.):
- Permanent node URL
- Example: https://www.lib.ncsu.edu/node/55107/
- URL alias
- Example: https://www.lib.ncsu.edu/hill/map
The URL alias is changeable. By default, Drupal generates an automatic URL alias, which usually the node title with hyphens between words (and stop words like the dropped). But we often customize the URL alias to align with our conventions.
How to customize a URL in Drupal
- While editing the page, go to to the right sidebar and open the URL Alias section.
- Un-check Generate URL Alias (if it's not already unchecked).
- Type your new URL alias into the text field. (Omit https://www.lib.ncsu.edu and start the URL alias with a slash.)
URL conventions
It should be human-readable.
Use hyphens in place of spaces. Spell out words; don't abbreviate much or at all.
- Please do: /data-and-visualization-spaces
- Please don't: /datavizspaces
It's okay to be verbose.
Long URLs are fine, if it's in the name of readability. URLs should give the user a hint about page content.
- Please do: /endowments/frank-and-judy-abrams-endowment
- Please don't: /endowments/fja
"But what if you're trying to spell out a long URL to someone at the Ask Us desk?" you ask. Good point! Fortunately, there's a "share this page" option above the footer on all Drupal pages. It includes a QR code that you can share quickly with a patron.
Use slashes to indicate conceptually nested content.
Slashes in a URL traditionally indicate directory structure. We echo that convention in URL aliases, even though Drupal is a just a sea of content in a database rather than a collection of folders.
- Please do: /hill/map
- Please don't: /hill-library-map
Often, we have put rules and structures in place that affect page layout or behavior based on the URL pattern. For instance, all nodes with a URL alias that begins with /hill/ will have the Hill Library menu in the left sidebar.
Redirects
How to create a redirect
If you change a node's URL alias, Drupal will automatically create a redirect from the old URL to the new one. Nice! No need to take further action.
Staff on the Web Team can also do this by going to Configuration > URL redirects.
How to edit a redirect
- While editing the page, go to to the right sidebar and open the URL Alias section. Un-check Generate URL Alias (if it's not already unchecked). Add -deprecated to the end of the URL alias. Save.
- Edit the page again. In the right sidebar, open URL Redirects. Edit the existing (latest, just-created) redirect.
- Change the “To” URL to whatever you want it to be.
(Note: there are several ways to edit redirects in Drupal. This is just one of them.)