Unique URLs and Redirection in Flask

I am unable to understand what this part of the Flask documentation is trying to convey regarding the use of trailing / in a URL string.
Can someone explain why would I need a trailing / and in which cases should I never use them?

If you are familiar with command line navigation, these two paths are the same

cd /my/file/path


cd /my/file/path/

The trailing slash has no effect. However, it seems that for Flask, the projects page is usually at /projects/ while the about page is usually at /about. These are just conventions, but Flask enforces them for you.

1 Like

Ok, I think I get this point but nowhere does the documentation speak of this convention. Also, why would a webpage have such a convention? I have built a couple of web projects with Flask and didn’t use the trailing slash at all.

The documentation discusses this convention right here

The canonical URL for the projects endpoint has a trailing slash. It’s similar to a folder in a file system. If you access the URL without a trailing slash, Flask redirects you to the canonical URL with the trailing slash.

The canonical URL for the about endpoint does not have a trailing slash. It’s similar to the pathname of a file. Accessing the URL with a trailing slash produces a 404 “Not Found” error. This helps keep URLs unique for these resources, which helps search engines avoid indexing the same page twice.

So , if I am getting this right, whenever I use about endpoint I should not use a trailing slash and when using projects endpoint I should use one slash \ ?

That’s my understanding as well.