Guides

Deduping Nodes

How to add multiple of the same node to your schema graph.

Deduplicating a node

When generating many of the Schema.org nodes a default global @id is used to help with best practices.

For example:

useSchemaOrg([
  defineOrganization() // generates the nodes with an #identity id
])

This allows the node relations to be automatically mapped for best practices.

useSchemaOrg([
  defineWebPage() // knows to link the #identity id
])

However, it can get in the way of configuring multiple nodes of the same type. To get around this you should provide your own @id on the node:

useSchemaOrg([
  defineOrganization({
    '@id': '#some-company'
  })
])

Replacing a node

If you're likd to replace a node, you can use provide a tagDuplicateStrategy to the useSchemaOrg composable.

useSchemaOrg([
  defineOrganization({
    '@id': '#some-company',
    'name': 'Bar Company',
    'url': 'https://bar.com',
  }),
])

useSchemaOrg([
  defineOrganization({
    '@id': '#some-company',
    'name': 'Foo Company',
  })
], {
  tagDuplicateStrategy: 'replace'
})

// Replaced!
// {
//   '@id': '#some-company',
//   name: 'Foo Company',
// }