DEV Community

GreggHume
GreggHume

Posted on • Edited on

7 3

jsonld in Nuxt 2, super simple, no plugins

On a page in the head method you can add jsonld like this:

  head() {
    return {
      script: [{
        type: 'application/ld+json',
        innerHTML: JSON.stringify(this.jsonld) // <- set jsonld object in data or wherever you want
      }],
      __dangerouslyDisableSanitizers: ['script'], // <- this is important
    };
  },
Enter fullscreen mode Exit fullscreen mode

In your browser use a data sniffer extension to see the results:

Chrome:
https://chrome.google.com/webstore/detail/openlink-structured-data/egdaiaihbdoiibopledjahjaihbmjhdj?hl=en

Firefox:
https://addons.mozilla.org/en-US/firefox/addon/openlink-structured-data-sniff/?utm_source=addons.mozilla.org&utm_medium=referral&utm_content=search

More info on Nuxt Head:
https://nuxtjs.org/docs/components-glossary/head/

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more