Menu

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

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

DEV Community: javascript·CapyLaunch·1 day ago
#bEyVt1ZL
#devtojavascript#devto#dev#pages#redirect
Reading 0:00
15s threshold

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.…

Continue reading — create a free account

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