nextjs-i18n-seolisted
Install: claude install-skill augchan42/inkstone
# Next.js i18n SEO Fix
Multilingual Next.js sites commonly ship with a crawlability-killing bug: locale redirects that use **307 Temporary** instead of **301 Permanent**. This means Googlebot never transfers PageRank to the actual indexed URL. Fix this first — it's a one-line change with immediate impact.
## The Core Problem
When a user (or Googlebot) hits `/hexagrams/14`, Next.js middleware redirects to `/en/hexagrams/14`. The default `NextResponse.redirect(url)` issues a **307 Temporary Redirect**. Google does not transfer PageRank on 307s. Result: any backlink to the clean URL is wasted.
**Pages Router** doesn't have this problem because `getStaticPaths` generates pages at their final URL with no redirect hop.
---
## Phase 1: Audit the Site
### 1. Check the redirect status code
```bash
curl -I https://example.com/some-page
# Look for: Location: and HTTP/2 301 vs 307
```
### 2. Check robots.txt
```
https://example.com/robots.txt
```
- All paths should be allowed (or only `/api/` blocked)
- Sitemap URL must be listed
### 3. Check the sitemap
```
https://example.com/sitemap.xml
```
- Are all pages listed with their final (locale-prefixed) URL?
- Are `alternates.languages` hreflang entries present?
### 4. Inspect the middleware
Look for `NextResponse.redirect(url)` — if no status code is passed, it's a 307.
---
## Phase 2: Fix the 307 → 301 Bug
**File: `src/middleware.ts`** (or `middleware.ts` at root)
```ts
// ❌ BEFORE — issues 307 Temporary Redirect
const respo