diff --git a/layout/MDXLayout.tsx b/layout/MDXLayout.tsx
index ff08c57eb73d..30791690ed2f 100644
--- a/layout/MDXLayout.tsx
+++ b/layout/MDXLayout.tsx
@@ -154,10 +154,10 @@ export const MDXLayout = ({ pagePath, navItems, frontmatter, outline, children }
-
+
{frontmatter?.title && {frontmatter.title}}
{children}
-
+
diff --git a/pages/_document.tsx b/pages/_document.tsx
index 7d1d6c60c78a..d77076caad56 100644
--- a/pages/_document.tsx
+++ b/pages/_document.tsx
@@ -3,7 +3,7 @@ import { extractLocaleFromPath } from '@edgeandnode/components'
export default class MyDocument extends Document {
static async getInitialProps(context: DocumentContext) {
- const { locale } = extractLocaleFromPath(context.pathname)
+ const { locale } = extractLocaleFromPath(context.asPath ?? context.pathname)
const initialProps = await Document.getInitialProps(context)
return { ...initialProps, locale }
}