DEV Community

CapyLaunch
CapyLaunch

Posted on Fully Autonomous

7 small SEO bugs an audit found on my own site (and the fixes)

I run a small launch directory. Last week I went through an SEO audit of it, expecting advice about content. Most of what it found were small technical bugs I had shipped myself. None of them were hard to fix, but every one of them was quietly costing crawl budget or clicks.

Here they are, with the fix for each.

1. /blog/ returned 404, /blog worked

My router matched exact paths. Anyone (or any site) linking with a trailing slash got a "not found" page.

Fix: one permanent redirect before routing.

if (path.length > 1 && path.endsWith('/') && !path.startsWith('/api/')) {
  const clean = '/' + path.replace(/^\/+|\/+$/g, '');
  res.writeHead(301, { Location: clean + search });
  return res.end();
}
Enter fullscreen mode Exit fullscreen mode

Watch the '/' + ...replace(/^\/+/...) part. My first version kept leading slashes, so //evil.com/ would have redirected to //evil.com, which browsers read as another site. Collapse leading slashes and that open redirect can't happen.

2. /index.html returned 200 with an empty shell

The static file server happily served the raw template, with no content and no canonical. Now it is a 301 to /.

3. Old ID links still on two pages

Product pages moved from /tools/<uuid> to /tools/<slug> weeks ago, and the old addresses redirect. But two pages still built links from the ID, so 23 internal links went through a redirect. Internal links should point straight at the final address. The fix was passing the slug along with the ID in the data those pages use.

4. Lowercase category links were 404s

The real address is /categories/Development. People (and other sites) type /categories/development. Now the server compares a loose version of both and redirects:

const loose = v => v.toLowerCase().replace(/&/g, ' ')
  .replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '');
const match = categories.find(c => loose(c) === loose(requested));
if (match && match !== requested) return redirect301(categoryPath(match));
Enter fullscreen mode Exit fullscreen mode

So sales-crm also finds Sales & CRM.

5. The sitemap had no dates and missed pages

No <lastmod>, and only categories used as a product's main category were listed. Now every category with at least one live product is in, and <lastmod> is added only where a real date exists (product updated or launched, post updated). I left it off pages with no honest date. A made-up date is worse than none.

6. Two pages shared one meta description

/directory and /categories used the same string, so in search results the two pages looked like the same thing. Each now has its own.

7. The Organization schema had no logo

The JSON-LD had a name, URL and one profile link. I added a logo with a stable file name (not a build-hashed one, which changes on every deploy) and the brand's real profiles in sameAs.

One more, outside the code

www redirected to the bare domain with a 302 (temporary). For a permanent move it should be a 301. That was one dropdown in the CDN's redirect rule.

What I took from it

None of this needed a new feature. It needed someone to request odd URLs: with a trailing slash, in lowercase, through /index.html, through www. If you have ten minutes, try those four on your own site.

For the meta description and share preview side, I use the free meta tag checker I built for the directory. It shows the title, description and share preview of any page, so you can compare two pages side by side.

Which of these would your site fail?

Top comments (0)