Giter Club home page Giter Club logo

trailing-slash-guide's Introduction

Trailing Slash Guide

Have trailing slash problems after deploying a static website in production?

This repo explains factually the behavior of:

We also suggest some possible solutions

Intro

Let's get more familiar with trailing slash issues.

Common problems:

  • SEO/perf issues: when browsing /myPath, your host redirects to /myPath/
  • 404 issues: relative link such as <a href="otherPath"> are resolved differently (/otherPath or /myPath/otherPath depending on the presence/absence of a trailing slash
  • UX issues: your host adds a trailing slash, and later your single-page-application frontend router removes it, leading to a confusing experience and flickering url

Causes:

  • static site generators can emit different files for the same path /myPath: /myPath.html or /myPath/index.html (the later can lead to an additional trailing slash)
  • host providers all have a different behavior when serving static files, there is no standard

Summary

Considering this static site:

static
│
├── file.html
│
├── folder
│   └── index.html
│
├── both.html
└── both
    └── index.html

Behavior of various static hosting providers:

Host Settings Url /file /file/ /file.html /folder /folder/ /folder/index.html /both /both/ /both.html /both/index.html
GitHub Pages link 💢 404 ➡️ /folder/
Netlify Default link ➡️ /file ➡️ /folder/ ➡️ /both
Netlify Pretty Urls on link ➡️ /file ➡️ /folder/ ➡️ /both
Netlify Pretty Urls off link
Vercel Default link 💢 404 💢 404
Vercel cleanUrls=false trailingSlash=undefined link 💢 404 💢 404
Vercel cleanUrls=false trailingSlash=false link 💢 404 💢 404 ➡️ /folder ➡️ /both
Vercel cleanUrls=false trailingSlash=true link 💢 404 💢 404 ➡️ /folder/ ➡️ /both/
Vercel cleanUrls=true trailingSlash=undefined link 💢 404 💢 404
Vercel cleanUrls=true trailingSlash=false link ➡️ /file ➡️ /file ➡️ /folder ➡️ /folder ➡️ /both ➡️ /both ➡️ /both
Vercel cleanUrls=true trailingSlash=true link ➡️ /file/ ➡️ /file/ ➡️ /folder/ ➡️ /folder/ ➡️ /both/ ➡️ /both/ ➡️ /both/
Cloudflare Pages link ➡️ /file ➡️ /file ➡️ /folder/ ➡️ /folder/ ➡️ /both ➡️ /both/
Render link
Azure Static Web Apps link 💢 404

Help Wanted

Let's keep this resource up-to-date, and make it exhaustive together.

trailing-slash-guide's People

Contributors

josh-cena avatar muescha avatar slorber avatar strift avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.