How to Enable or Disable Trailing Slashes in WordPress Links

WordPress allows total control of your link structure and you can set it in the permalink settings. Based on your preference, you can enable or disable the use of trailing slash in WordPress category, tag and post URLs. The structure is important for SEO and trailing slashes might have an impact on it.

If you are not sure what a trailing slash at the end of a URLs is, here are examples:

  • A link with a trailing slash: http://wpcraze.com/create/
  • A link without a trailing slash: http://wpcraze.com/create

WordPress and its permalink settings seem to redirect to either one of these and it has some impacts on your site’s search engine ranking. Both links shown above are treated differently by Google. Here’s the official word on it from Google Webmaster Central Blog.

Here’s how you can enable or disable the use of trailing slash in WordPress links that host your content:

  • After logging into the admin dashboard, click on Settings and Permalinks.
  • To enable it: Make sure that there’s a slash at the end. (Example: http://wpcraze.com/%postname%/)
  • To disable it: Remove the slash at the end. (Example: http://wpcraze.com/%postname%)

Wait, but there’s more…

If you choose the custom structure in such a way that the posts end in .html or /%postname%.html, then you will see that your category links won’t have a trailing slash at the end. If you don’t mind it, then just let it be. If you want to solve it, adding a slash ‘/’ after .html like /%postname%.html/ will not be the optimum solution because now your blog posts ending in .html will also have trailing slashes.

What we actually want to achieve is—avoid the slash in .html links and keep it for the category links.

Here’s the solution:

You have to use a plugin to force trailing slash on category and tag URLs. One such plugin that can do it is the wildly popular and quite useful one called Yoast SEO. The following tutorial is based on it, because chances are that you already have it installed (it is recommended to be installed after starting a WordPress site):

After making sure you have Yoast SEO plugin:

  • Navigate to SEO > Advanced in the admin dashboard.
  • Click on the Permalinks
  • Tick the option that says, “Enforce a trailing slash on all category and tag URL’s

Now, it is guaranteed that your category and tag links will have a trailing slash at the end.