Skip to content

Metadata duplication in <head> when using next-intl middleware with locale redirects #80529

@jjtsou

Description

@jjtsou

Link to the code that reproduces this issue
Live: https://job-board-chi-indol.vercel.app/

To Reproduce

  1. Set up next-intl middleware for internationalization.
  2. Configure locale routing with redirects from / to /[locale].
  3. Export a generateMetadata function in a page component.
  4. Navigate from / to a locale path (e.g., /en).
  5. Inspect the HTML output in browser DevTools.

Example code:

// middleware.ts
import createMiddleware from 'next-intl/middleware';
import { routing } from './src/i18n/routing';

export default createMiddleware(routing);

export const config = {
  matcher: ['/', '/(en|el)/:path*']
};
// src/i18n/routing.ts
export const routing = {
  locales: ['en', 'el'],
  defaultLocale: 'en',
  localePrefixMode: 'always'
} as const;
// app/[locale]/page.tsx
export async function generateMetadata({
  params,
  searchParams,
}: Props): Promise<Metadata> {
  const { locale } = await params;
  const t = await getTranslations({ locale, namespace: "meta" });

  return {
    title: t('title'),
    description: t('description'),
    openGraph: {
      title: t('title'),
      description: t('description'),
      type: "website",
      locale,
    },
  };
}

Current vs. Expected behavior
Following the steps from the previous section, I expected the metadata to appear only once in the <head> section when redirecting between routes. However, metadata tags (title, description, Open Graph, etc.) are duplicated in the HTML output after locale redirects.

<!-- Expected: Single metadata -->
<head>
  <title>Job Board</title>
  <meta name="description" content="Find jobs..." />
</head>

<!-- Actual: Duplicated metadata -->
<head>
  <title>Job Board</title>
  <title>Job Board</title>
  <meta name="description" content="Find jobs..." />
  <meta name="description" content="Find jobs..." />
</head>

Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 24.4.0

Binaries:
Node: 21.6.2
npm: 10.2.4
Yarn: N/A
pnpm: N/A

Relevant Packages:
next: 15.3.2
eslint-config-next: N/A
react: 19.1.0
react-dom: 19.1.0
typescript: 5.8.3
next-intl: 4.1.0

Next.js Config:
output: N/A

Which area(s) are affected?

  • 'Metadata'
  • 'Middleware'
  • 'Redirects'

Which stage(s) are affected?

  • 'Vercel (Deployed)'

Additional context

  • Issue does NOT occur with static metadata exports.
  • Only happens with generateMetadata function during locale redirects.
  • Metadata merging behavior seems inconsistent with documented behavior.
  • The issue is reproducible on deployed (Vercel) environments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalid linkThe issue was auto-closed due to a missing/invalid reproduction link. A new issue should be opened.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions