How to use a trailing slash in URLs correctly: SEO best practices

The trailing slash is often overlooked in link creation and site structure. But this little attribute is crucial to search engines’ perception of your domain, link equity and, ultimately, site rankings. 

What is the trailing slash?

The trailing slash, also known as the forwarding slash, is a slash that appears after the domain or URL name. Here’s how it looks like:

The primary purpose of the trailing slash is to differentiate between folders, subfolders or categories in a URL.

The URL string is subject to certain character restrictions, as it only allows alphanumeric characters and a handful of special characters (;, /, ?, :, @, &, =, +, $, -, _, ., !, ~, *, ‘, (, ), #) that may carry specific meanings. For this reason, Google treats each character variation in a URL as a separate page, and adding a trailing slash or double slashes to the URL signals to Google that it is a distinct page that should be crawled and indexed separately.  

Trailing slash after the domain name 

In his blog, Google Search Advocate John Mueller indicates that the presence or absence of a trailing slash after the domain name is not a significant issue.

Consider these examples of URLs:

Trailing slash examples

Now, see when trailing slashes cause duplicate: 

 

Examples of trailing slashes that cause duplicates

All domains, whether they have a trailing slash at the end or not, are treated equally, and there is no need to be concerned about it. 

However, there are other circumstances where trailing slash matters and should be given attention. Here are some instances: 

Trailing slash after file names 

Trailing slashes after file names — such as .pdf, .html, .css, .jpeg and .webp — often confuse systems. If you use them, Google may mistake the file for a folder, assume there’s no content after that path and return a 404 server response

You can test this yourself by adding a trailing slash to one of your PDF files if you’re curious.

trailing slash with pdf

Checking for trailing slash issues as a best SEO practice

There are several tools and methods available to identify any trailing slash-related issues on your website. For instance, you can use Screaming Frog to crawl your website — if both options (with and without trailing slash) are present, it can help you identify different error types such as meta title duplicates, H1 duplicates and so on.

Another option is to manually type the webpage address with and without the trailing slash directly into your browser and check for any redirects. Alternatively, you can use a redirect checker to verify that both options of the page yield a 200 server response.

Here are the two most common trailing slash issues that can impact your search engine optimization (SEO) results

1. Canonicals tag is not the same as trailing slash usage in URL 

The canonical tag is a type of HTML tag that signals to search engines that a particular URL is the primary or master copy of a webpage and should be crawled accordingly. In most cases, the canonical tag is self-referencing, meaning it points back to the same page. This tag is crucial to ensure that the self-referencing canonical tag matches the usage of the trailing slash in the main URL. For example, if the main URL is https://productiveshop.com/seo-audit/, the canonical tag should also contain a trailing slash, as shown below:

check canonical in html

It is a common practice to have both types of URLs on a website and to use canonical tags to indicate the proper version. For instance, if a website has two pages with similar URLs like https://productiveshop.com/seo-audit/ and https://productiveshop.com/seo-auditboth pages can use a canonical tag pointing to the correct version, which is https://productiveshop.com/seo-audit/

Generally, this solves the problem and is acceptable for smaller sites. However, for larger websites, it can be challenging to crawl and understand the site structure, resulting in a higher crawling budget for search engines. In my opinion, having a clean and well-structured website is essential for better rankings and indexation.

2.Hreflang URL does not correspond with page URL

Hreflang is a tag attribute that signals to Google the language you’re using on a specific page. This tag enables search engines to serve the right page to users searching in the language of your tag.

If your website has multiple languages, it is essential to ensure that the hreflang link is precisely the same as the one that should be indexed and used in canonical tags. You can check this manually in the page code or use various crawlers like Netpeak Spider or Screaming Frog. 

If the canonical tag points to a page version with a trailing slash, but the hreflang tag points to a page version without a trailing slash, search engines may not respect these hreflang tags. Therefore, it is critical to maintain consistency across all elements of a multilingual website to avoid confusion for search engines and ensure proper indexing.

🏷️ Find out all the SEO issues your B2B website might have. Check out our SEO audit checklist.

Which version to choose: with or without trailing slash?

Choosing whether to use a trailing slash or not in your URL is not particularly important, but having a consistent option across your website helps with organization and optimizes your site for search. 

If both versions with and without trailing slashes are open for crawling and indexed, it’s best to select the version that brings more traffic or is better indexed. You can compare this in Google Analytics or Google Search Console to determine which version is preferred by Google. If your website receives very little traffic, you can check for the version that is currently indexed through a Google search.

Here’s how you can check for pages that have been indexed:

  1. Add your URL with or without trailing slash in Google search after Google operator site.
  2. Hover the mouse over the title of indexed page. 
  3. In the bottom left corner of your browser page, you will see the URL preferred by Google. 

how to check the indexation of the page

The takeaway: After choosing the preferred version of your URL, it’s important to ensure that all internal links on your website use the same URL structure. You should set up a 301 redirect from the non-preferred version to the preferred page. Both the canonical tags and hreflang tags should use the same URL structure as your preferred version. 

Finally, verify that your sitemap (both XML and HTML versions) contains links with the proper URL structure. By following these steps, you can ensure that your website is properly structured and easily crawlable for search engines.

How to add or remove trailing slashes on your WordPress website? 

Whether you choose to add or remove trailing slashes, you can make those edits in the admin panel of WordPress. You just need to have admin rights, log in, choose settings/permalinks and then include or remove trailing slash from all pages. 

Here’s how to do this: 

/%postname%/ — Adds a trailing slash at the end

/%postname% — Removes a trailing slash

Screenshot of WordPress admin panel for trailing slash settings

If you change your trailing slash settings, then WordPress will automatically enforce your chosen version. Any new pages arising from the trailing slash change will have 301 redirects from the old page. WordPress will also change internal links and canonical tags, update the sitemap and make other necessary adjustments.

Trailing slash issue in Google Analytics: how to set up correctly   

If you have already addressed all the issues related to trailing slashes mentioned earlier, then this particular issue may not be relevant to you. However, some websites may not allow you to set up redirects or perhaps you may lack the necessary development resources. In such cases, it is essential to configure proper Google Analytics reporting to avoid any confusion in your SEO reports.

To do this, you can create a new filter with a clear name such as “Removing Trailing Slash.” Select “Custom,” then “Advanced.” In the string Field A -> Extract A enter “^/(.*)/$,” and in the Output to -> Constructor “/$A1”. 

See the screenshot below: 

screenshot of Google Analytics filter that shows how to remove trailing slash

Analytics cannot provide a preview for this filter as previews for advanced and location-based filters (e.g., IP address, country) are not supported at this time. To view the impact, save this setting and check the real-time report to see the way URLs are shown (there should be no trailing slash).  

Google Analytics real-time report

 

👉Still need help setting trailing slashes correctly? Get in touch with our SEO consultants

Frequently asked questions 

What is a trailing slash in URL?

The trailing slash is a forward slash that comes after the domain or URL. For example, a URL that includes a trailing slash will look like this: https://productiveshop.com/oxford-comma-b2b-copywriting/, while a URL without a trailing slash would look like this: https://productiveshop.com/oxford-comma-b2b-copywriting.

How to add trailing slash to URL?

If you want to add slash with .htaccess, you need to update the code as follows: 

RewriteCond %{REQUEST_FILENAME} !-f 

RewriteRule ^(.*[^/])$ /$1/ [L,R=301]

Important:  !-f looks for a file and if the file exists, it doesn’t add the trailing slash. This keeps images, PDFs, JS, CSS etc. from breaking.

If you need to add or remove trailing slashes in WordPress, see the section of this post on “How to add or remove trailing slashes on your WordPress site.”

Is missing a trailing slash in a URL bad for SEO?

No, it is not a problem. Google doesn’t care if the page has a forwarding slash or not. However, you do need to check that all your pages have the same logic and don’t have a trailing slash. 

Is it important to keep the same trailing slash rules after migration?

Yes. Whether you’re creating a new website or making changes to an existing one, it is imperative to maintain a consistent URL structure (having a trailing slash or not having it). Inconsistencies in URLs can lead to various issues, including the need to set up redirects and a temporary decrease in rankings during the Google bot’s reindexation process. To gain a deeper understanding of this topic, I recommend referring to our comprehensive enterprise migration guide. It provides valuable insights and guidance on managing website migration smoothly and effectively.

Why do some URLs have two slashes? 

Double slashes in the URL path can occur when the website has relative linking issues. This problem can also be caused by human factors, mostly because of inattentiveness. Sometimes people can mistakenly add two slashes to the link — and if there is no canonical or redirect, it can also be crawled and indexed by Google.  

To pinpoint the source of the problem and rectify it, you may need assistance from a developer. By setting up appropriate 301 redirects, you can ensure that any traffic or link equity associated with the URL with a double slash is redirected to the correct URL. This helps maintain the integrity of your website’s link structure and prevents any negative impact on user experience and SEO.

Marina Iermolaieva

Marina Iermolaieva

Marina Iermolaieva is an SEO Consultant in Productive shop. She has extensive knowledge of search engine optimization techniques, including keyword research, on-page optimization and technical SEO. She is skilled in analyzing website performance metrics and creating customized SEO strategies that are tailored to meet the needs of clients. In her free time, Marina travels and tastes local food.

Get the latest blog updates from Productive Shop! Subscribe to our blog:

    Top