Four frontend skills are on sale now. Pay once, download straight away with your licence key.

See the catalogue
AI Skill Up
Browse skills

The trailing slash that kept our pages out of Google

Our canonicals said /skills/x, the server answered at /skills/x/, and Google indexed neither. How to spot the mismatch and the one function that fixes it.

Our homepage was indexed within a day. The product pages were not, and Search Console said something odd about them: URL is unknown to Google, with no referring sitemap, even though every one of them was in the sitemap Google had read successfully that morning.

What was actually happening

The site is prerendered, so each page is a file at /skills/glass-instrument-ui/index.html. The host serves that at /skills/glass-instrument-ui/ and answers the slash-less form with a redirect to it. That part is normal. The bug was everything we published about the page:

WhereWhat it saidWhat the server does with it
Canonical tag/skills/glass-instrument-ui307 to the slash form
Sitemap/skills/glass-instrument-ui307 to the slash form
Internal links/skills/glass-instrument-ui307 to the slash form
The page itselfserved at /skills/glass-instrument-ui/200

So Google was told the real address of the page is one that immediately sends it somewhere else. The blog index got the other symptom: Alternative page with proper canonical tag, because its canonical pointed at /blog while it lived at /blog/.

How to check your own site in two minutes

curl -sI https://example.com/some-page | head -1
curl -sI https://example.com/some-page/ | head -1
curl -s https://example.com/some-page/ | grep -o 'rel="canonical" href="[^"]*"'

Whichever form answers 200 is your real URL. The canonical in the page must be exactly that string, and so must the sitemap entry. If they disagree, you have found it.

The fix is one function, not a hundred edits

We build every absolute URL through one helper, so the fix lived in one place: add a trailing slash to any page path, and leave anything with a file extension alone so images and sitemap.xml are untouched. The sitemap generator got the same rule, and every internal link was rewritten to the served form so crawlers never take the extra hop. Over nine hundred internal links changed; the logic that decides the shape is six lines.

After deploying, resubmit the sitemap and use URL Inspection on a few key pages. Pages Google had already filed as alternates will be recrawled; that part takes days, not minutes. The broader checklist for a young site is in Search Console for a new site, and the sitemap rules we follow are in a sitemap for a static site.

Questions

Does a trailing slash matter for SEO?

Not which one you choose, but that you choose one. The canonical tag, the sitemap and every internal link should point at the exact URL your server returns with a 200. If any of them points at a form that redirects, Google gets two answers and may index neither.

What does 'Alternative page with proper canonical tag' mean?

Google found the page but decided another URL is the real one, because that is what your canonical tag said. It is correct behaviour when you have duplicates. It is a bug when the canonical points at a URL that only redirects back.

Should I use a 301 or a 307 for the slash redirect?

Either works for crawlers once canonicals are right, and many static hosts choose for you. What matters more is that nothing you publish, not the sitemap, not a canonical, not a link, sends a crawler through the redirect at all.

Or skip the afternoonand drop one in.

Every skill in the catalogue is a folder you drop into your skills directory. Each ships with its design rules, worked examples and a troubleshooting table, and downloads the moment you pay.