feat(web): hreflang alternates, sitemap.xml and robots.txt; staging noindex (MITHOME-116)

src/lib/seo.ts is the single source for page alternates (self canonical
+ hreflang hu/en/x-default), sitemap entries (every page in both
languages, with alternates) and robots rules. Per the user's decisions
every page is announced in both languages regardless of the English
approval status, and staging is never indexed: robots.txt disallows
all, the sitemap is empty and every page carries a noindex meta.

Home and catch-all page metadata now carry alternates and a locale-
correct og:url. Staging smoke SMOKE-09 checks hreflang, canonical,
noindex and robots.txt. Documented in architecture.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Do Siki
2026-09-29 12:36:12 +02:00
co-authored by Claude Opus 5.5
parent facc5db641
commit 2fd5c9bc8b
9 changed files with 162 additions and 4 deletions
+45
View File
@@ -0,0 +1,45 @@
import { absoluteUrl, isIndexingDisabled, pageAlternates, robotsRules, sitemapEntries } from './seo'
const SITE = 'https://mozdit.hu/'
describe('SEO helpers (MITHOME-116)', () => {
it('should build absolute URLs without double slashes', () => {
expect(absoluteUrl('/hu/rolunk', SITE)).toBe('https://mozdit.hu/hu/rolunk')
})
it('should give each page a self canonical and hreflang pairs with x-default', () => {
expect(pageAlternates('en', 'services', SITE)).toEqual({
canonical: 'https://mozdit.hu/en/services',
languages: {
hu: 'https://mozdit.hu/hu/szolgaltatasok',
en: 'https://mozdit.hu/en/services',
'x-default': 'https://mozdit.hu/hu/szolgaltatasok',
},
})
expect(pageAlternates('hu', undefined, SITE).languages).toEqual({
hu: 'https://mozdit.hu/hu',
en: 'https://mozdit.hu/en',
'x-default': 'https://mozdit.hu/hu',
})
})
it('should list every page in both languages in the sitemap', () => {
const entries = sitemapEntries(SITE)
expect(entries).toHaveLength(12)
expect(entries.map((e) => e.url)).toEqual(
expect.arrayContaining(['https://mozdit.hu/hu', 'https://mozdit.hu/en', 'https://mozdit.hu/en/privacy-policy', 'https://mozdit.hu/hu/felhasznalasi-feltetelek']),
)
const privacy = entries.find((e) => e.url.endsWith('/en/privacy-policy'))!
expect(privacy.alternates?.languages).toMatchObject({ hu: 'https://mozdit.hu/hu/adatvedelem' })
})
it('should block all crawling on staging and publish the sitemap elsewhere', () => {
expect(isIndexingDisabled('staging')).toBe(true)
expect(isIndexingDisabled(undefined)).toBe(false)
expect(robotsRules('staging', SITE)).toEqual({ rules: { userAgent: '*', disallow: '/' } })
expect(robotsRules(undefined, SITE)).toEqual({
rules: { userAgent: '*', allow: '/', disallow: ['/admin', '/api/'] },
sitemap: 'https://mozdit.hu/sitemap.xml',
})
})
})