How do I change the url Slug?

I was wondering how we could change the slug (aka the part after the https://project.glitch.me/ I really don’t like how my projects are like https://project.glitch.me/page.html.

Hi,

It depends on how your project is set up (static site, i.e. remixed from hello-website, or Express) and what you want the URLs to look like :slight_smile:

If you were just trying to get rid of the .html extensions, you have two options:

  • In static site, create a directory for each page (like /about/), put the existing HTML in that directory, and rename it to index.html. Now you can go to https://project.glitch.me/page/ and it will automatically go to the index of that directory.

  • In an Express site, when you set up the routing, you can customize the GET route for each page, to direct them to whichever page you want to serve:

app.get("/about/", (request, response) => {
  response.sendFile(__dirname + "/views/about.html");
});
8 Likes