Option to remove the trailing slash from links

Description

We should allow users decide if they want their urls to end with or without a trailing slash in Frontity.

Right now, in order to normalize all the links, Frontity add a trailing slash at the end of all the urls. This is the default behaviour in WordPress and it automatically redirects the url not ending in a slash to the same url with a slash. This is important for SEO purposes because search engines treat these urls separately even though they have the same content.This means you need a redirection and a cannonical url to prevent duplicated content.

However, some users will prefer to keep the urls without the trailing slash. In WordPress, this is possible changing the posts permalink. If you define it like /%postname instead of /%postname/ all your urls for the posts, categories, pages, etc won’t have the trailing slash.

In Frontity, you can achieve that modifying the normalize function from your theme as explained in this CodeSandbox, but we should provide an official setting for this.

We shouldn’t only change the url in the nav bar but also all the internal linking. This way, all the links included in the content (in an archive for example), should point to the cannonical url (with or without the slash) that users select to prevent an unnecessary redirection.

Functionalities

  • Allow users to select if they want their urls to end with or without a trailing slash.

Requirements

  • Combined with the redirections feature, we should handle this redirection, one way or another, from Frontity so it doesn’t affect SEO.

Dependencies

Possible solution

We could have an option in source to define if you want or not the trailing slash, keeping the default behaviour as it is right now because it is the same as WordPress. Depending the option selected here, we could redirect one way or the other.

@christianoliveira As far as we understood this is pretty important for SEO and we should consider mainly two things here:

  • We should create redirections to the cannonical urls users select (with or without the trailing slash).
  • All the internal linking should point to the cannonical urls users select.

Is this correct? Could you please confirm if there is something we are not considering?

@SantosGuillamot that’s super correct! If URLs have self-referencing canonical tags, those should also point to the preferred URL format.

Only thing I could add maybe is that if you are currently creating/processing sitemaps, they should include the canonical URLs.

Let me know if you have any doubt!

2 Likes

@christianoliveira & @SantosGuillamot
Can you please show me the steps to get rid of the last slash from all the web pages?

Thank you in advance.