cmux/web
Lawrence Chen 46589f531c
Fix SEO indexing: hreflang, canonicals, sitemap, trailing slash (#2193)
* Fix SEO indexing: add hreflang, canonicals, sitemap per-locale entries

Google Search Console showed 380 not-indexed vs 86 indexed pages.
Root causes: missing hreflang tags on rendered pages (only in sitemap),
no canonical on homepage, inconsistent canonicals wiping parent hreflang,
sitemap only listing English URLs, trailing slash duplicates, and
_next/static chunks being crawled as pages.

Changes:
- Add buildAlternates() utility for consistent canonical + hreflang
- Add hreflang tags to all pages via alternates.languages in metadata
- Add self-referencing canonical URLs to every page (homepage had none)
- Expand sitemap to emit separate entries for each locale
- Add missing /docs/custom-commands to sitemap
- Remove skipTrailingSlashRedirect to normalize trailing slashes
- Block /_next/ in robots.txt to stop chunk crawling

* Add per-page alternates to docs sub-pages and blog index

Docs sub-pages and blog index only returned title/description in
generateMetadata, so they inherited the parent layout's alternates
(pointing to /docs or /blog). Now each page sets its own
buildAlternates() with the correct path so canonical and hreflang
point to the actual page URL.

* Derive openGraph.url from buildAlternates to avoid drift

* Redirect non-English legal pages to English, remove from sitemap

Legal pages (privacy policy, TOS, EULA) are untranslated English content.
Serving them under every locale creates 54 duplicate URLs. Now:
- Middleware 301-redirects /ja/privacy-policy etc. to /privacy-policy
- Sitemap only includes English URLs for legal pages (no locale variants)
- Legal page metadata uses static English-only canonical

* Fix legal page redirect to only match /<locale>/<page> paths

endsWith matched too broadly (e.g. /docs/eula). Now only redirects
when the path after the first segment is an exact legal page match.

* Skip next-intl for legal pages to prevent locale redirect loop

Without this, a Japanese user hitting /privacy-policy could be
redirected by next-intl to /ja/privacy-policy, which our middleware
redirects back to /privacy-policy, creating a loop.

* Rewrite legal pages to /en/ instead of NextResponse.next()

Pages live under app/[locale]/, so skipping next-intl entirely
would break route resolution. Rewrite to /en/privacy-policy etc.
so Next.js can resolve the [locale] segment correctly.

---------

Co-authored-by: Lawrence Chen <lawrencecchen@users.noreply.github.com>
2026-03-26 15:10:39 -07:00
..
app Fix SEO indexing: hreflang, canonicals, sitemap, trailing slash (#2193) 2026-03-26 15:10:39 -07:00
i18n Fix SEO indexing: hreflang, canonicals, sitemap, trailing slash (#2193) 2026-03-26 15:10:39 -07:00
messages feat: cmux.json for custom commands (#2011) 2026-03-24 22:28:46 -07:00
public Add /nightly page (#1378) 2026-03-13 07:41:30 -07:00
.env.example Add sidebar help menu to footer (#958) 2026-03-05 21:00:42 -08:00
.gitignore Add landing page (web/) with Next.js + Tailwind 2026-02-09 20:51:27 -08:00
bun.lock Internationalize website with next-intl for 19 languages (#1216) 2026-03-12 05:36:58 -07:00
eslint.config.mjs Add landing page (web/) with Next.js + Tailwind 2026-02-09 20:51:27 -08:00
next.config.ts Fix SEO indexing: hreflang, canonicals, sitemap, trailing slash (#2193) 2026-03-26 15:10:39 -07:00
package-lock.json Internationalize website with next-intl for 19 languages (#1216) 2026-03-12 05:36:58 -07:00
package.json Internationalize website with next-intl for 19 languages (#1216) 2026-03-12 05:36:58 -07:00
postcss.config.mjs Add landing page (web/) with Next.js + Tailwind 2026-02-09 20:51:27 -08:00
proxy.ts Fix SEO indexing: hreflang, canonicals, sitemap, trailing slash (#2193) 2026-03-26 15:10:39 -07:00
README.md Update landing page: switch to Bun, add view transitions and UI polish 2026-02-09 22:01:53 -08:00
tsconfig.json Add landing page (web/) with Next.js + Tailwind 2026-02-09 20:51:27 -08:00

This is a Next.js project bootstrapped with create-next-app.

Getting Started

First, run the development server:

npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev

Open http://localhost:3000 with your browser to see the result.

You can start editing the page by modifying app/page.tsx. The page auto-updates as you edit the file.

This project uses next/font to automatically optimize and load Geist, a new font family for Vercel.

Learn More

To learn more about Next.js, take a look at the following resources:

You can check out the Next.js GitHub repository - your feedback and contributions are welcome!

Deploy on Vercel

The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.

Check out our Next.js deployment documentation for more details.