Skip to content

Head meta tags are omitted depending on attribute order #5362

Description

@Wakeful-Cloud

Describe the bug

mergeHead rigidly assumes that the first attribute in each head item is the name/key. Not only is this is not documented, but if a user wanted to have multiple meta tags with different names but the same content (e.g., og:image and og:image:url), they must take care to put the name attribute before the content attribute, otherwise VitePress will only output the final meta tag.

Reproduction

Reproduction example. Add the below to the VitePress config file:

  // ...
  head: [
    // Only the second meta tag will show up in the final HTML:
    // <meta content="contentA" name="name2">
    [
      "meta",
      {
        // Order of attributes matters here!!!
        content: "contentA",
        name: "name1",
      }
    ],
    [
      "meta",
      {
        // Order of attributes matters here!!!
        content: "contentA",
        name: "name2",
      }
    ],

    // Both of these meta tags will show up in the final HTML:
    // <meta name="name3" content="contentB">
    // <meta name="name4" content="contentB">
    [
      "meta",
      {
        // Order of attributes matters here!!!
        name: "name3",
        content: "contentB",
      }
    ],
    [
      "meta",
      {
        // Order of attributes matters here!!!
        name: "name4",
        content: "contentB",
      }
    ]
  ],
  // ...

Note how the attribute order changes (i.e., content before name for the first two tags, then name before content for the latter two tags).

Expected behavior

I expect VitePress to not silently omit meta tags. Moreover, I expect to be able to repeat meta tags (e.g., author, regardless of the order of the attributes within each head item object.

System Info

System:
    OS: Linux 7.0 Ubuntu 26.04 LTS 26.04 LTS (Resolute Raccoon)
    CPU: (16) x64 AMD
    Memory: 5.76 GB / 17.88 GB
    Container: Yes
    Shell: 5.3.9 - /bin/bash
  Binaries:
    Node: 24.16.0 - /run/user/1000/fnm_multishells/147846_1786511297976/bin/node
    npm: 11.13.0 - /run/user/1000/fnm_multishells/147846_1786511297976/bin/npm
  npmPackages:
    vitepress: ^2.0.0-alpha.19 => 2.0.0-alpha.19

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    contribution welcomeThe team would welcome a contribution from the community for this issuedocsImprovements or additions to documentation

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions