Menu

Astro trailing slash: three places that must agree, and how to check them
πŸ“°

Astro trailing slash: three places that must agree, and how to check them

DEV Community: astroΒ·SitePostmortem editorΒ·about 1 hour ago
#vP158eGG
#devtoastro#devto#dev#redirect#sitemap
Reading 0:00
15s threshold

The trailing slash is not cosmetic. It decides which URL your host answers without a redirect , and everything else you write β€” internal links, canonical, sitemap β€” has to agree with it.

With build.format: 'directory' , Astro emits page/index.html . A static host then serves /page/ directly and sends /page through a 308 to get there. Measured on a site using trailingSlash: 'always' plus the directory format:

curl -o /dev/null -w "%{http_code} %{redirect_url}" https:// < site > /about 308 https:// < site > /about/

Enter fullscreen mode

Exit fullscreen mode

One extra hop per internal link, invisible in the browser, paid by every crawler and every first-time visitor.

The three declarations

Config β€” trailingSlash and build.format decide the on-disk shape, which decides what the host serves without a redirect.

Links in the markup β€” every href you typed by hand, in markdown and in components.

canonical and the sitemap β€” declarations of address, not navigational links.

always and never are both…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.