Open
Description
Localization SEO is missing currently. It's even noted in the README file:
What is missing:
- opinion how to localize slugs
this highly depends where your data comes from. This will probably differ from project to project.- cross-links between your language slugs
like mentioned above, this will differ from project to project. You can find useful resources here:\
This can be solved by implementing Link
headers.
This is fairly simple to do, and can be done in the hooks.ts file. Here's what i came up with.
// src/hooks.ts
export const handle: Handle = async ({ event, resolve }) => {
const response = await resolve(event);
const [, lang, ...crumbs] = event.url.pathname.split('/')
const host = event.request.headers.get("host");
response.headers.set(
"Link",
locales.map(
(locale: Locales) =>
`<${[host, locale, crumbs].join("/")}>; rel="alternate"; hreflang="${locale}"`
).join(", ")
);
const body = await response.text();
return new Response(body.replace('<html lang="en">', `<html lang="${lang}">`), response)
};
It works without a problem in my testing.
Metadata
Metadata
Assignees
Labels
No labels