News & Blog

The URL Switcheroo

News & Blog

How to Swap URLs in Drupal

One of the great things that Drupal does for you is to automatically assign a “friendly” URL alias to a page, based on the title of the page. For example, if I were planning to build this blog article as a Drupal page, it would automatically assign the URL alias as /url-switcheroo.

Sometimes you find that you want a new page to have a URL alias that is already in use on your website. Recently, a client who works in the global health space added a section to their website about COVID-19 and their response to it worldwide. During this work, they found that they wanted a new page to have a URL that was already in use on one of their recently-created pages. But if Drupal is automatically assigning the URLs, is there any way to do this?

Yes, it only takes two steps:

  1. Change the URL on the Old Page.
  2. Change the URL on the New Page.

Step 1: Change the URL on the Old Page

To change the URL alias on the Old Page, you need to edit it from the Content menu. Then, scroll to the bottom of the Edit page, until you see the tabs for settings. The one you want is URL Path Settings.

This setting is probably set to automatically create nice URLs for you. As you can see, the “Generate automatic URL alias” is checked here, so I cannot edit the URL alias below.

Once you uncheck this setting, you can edit the URL alias. Choose an alias that makes sense for the content. It’s usually best to use the title of the page, as the Automatic URL alias feature does, and you can tweak it to find the best URL for the page.

Of course, since this is Drupal, you must click Save for the change to become real. The Save button is at the very bottom of the Edit page.

Step 2: Change the URL on the New Page

This step works exactly like Step 1. Edit your New Page from the Content menu, and scroll to the tabs near the bottom of the Edit page.

Select the URL path settings tab, and uncheck the Generate automatic URL alias checkbox.

Now you can enter the URL you want to use on the New Page. Once you enter the new URL, don’t forget to click Save.

Step 3: Check Your Work

Wait, wasn’t this a two-step process? Yes, but we always need to check our work. On the Content page, you can hover your mouse over the titles of the two pages you edited, and a small popup will show you the URL for the page. When you click, you should be taken to the page at its newly-assigned URL.

And that’s it! Now you have the best of both worlds: Drupal is automatically assigning URL aliases that are human-friendly and SEO-friendly, and you are able to override this when you need to.

Contact us today if you have any questions, want to discuss Drupal, or any other tech topic.

We take processes apart, rethink, rebuild, and deliver them back working smarter than ever before.