Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

General Discussion

Alex Watts
Alex Watts
8,396 Points

Clean URLs

Hello,

I am creating a website, but do not want the file extension in the URL to show.

This is what I do not want: www.example.com/about.html

This is what I want: www.example.com/about/

Thanks!

2 Answers

David Bath
David Bath
25,940 Points

The simplest way to accomplish this (with just a plain HTML website) is to create an "about" folder as you have in the URL and then give the page name "index.html" inside that folder. Hosts will default to looking for an index page, but don't typically put that in the URL, so long as your links to that page only refer to the folder and not the "index.html" page itself.

Alex Watts
Alex Watts
8,396 Points

Hello David,

Perfect! Is this, however, best practice?

Thanks!

David Bath
David Bath
25,940 Points

Hi Alex,

I don't think it's a bad practice. I've used this technique myself. You get clean and memorable URLs this way. You probably wouldn't do this for every page on a website (it would require creating a new folder for every page!), but for the top-level page of each section it would make sense.

Regards, David

Kevin Korte
Kevin Korte
28,149 Points

For a super simple site it's fine. For a more dynamic site, you would generally have a router, so you could create whatever url you wanted and route that url to a view template, and retrieve whatever data it needed to display to the user.

When I was first starting though, and building basic static sites, this is what I did.

So all this to say, big sites don't do it like this. When you sign up at youtube, they're not created a new folder on their server with your username, but they are routing that url to a view, with data about you.