Defining Metadata

Set global and per-page SEO metadata for your DocLayer app

Metadata is a crucial part of any application, covering information like page titles, descriptions, keywords, and more, including SEO-related data. Managing metadata effectively helps promote your product, improve discoverability, and enhance how your website or documentation appears in search results and social platforms. DocLayer provides comprehensive support for metadata management, giving you flexibility of customization you need.

This guide explains how to manage metadata effectively. Be aware that some portions of the data are resolved automatically and distributed wisely to avoid interpretation conflicts or unnecessary overwrites.


There are two main ways to manage metadata in your application:

  • globally, for the entire app, distributed downwards,
  • locally, for individual pages.

Let's explore both to see how you can achieve the most effective setup.

Global metadata

The primary place to define your metadata is the app.config.ts file. Inside its meta property, you can set the global metadata for your application. This means every page will automatically inherit these setting - such as page title, description, keywords, and more. For more flexibility, you can also use environment variables.

More on how to define and configure global metadata you can read here.

Open Graph tags

Globally, Open Graph (og) tags such as og:title and og:description are automatically generated based on the primary metadata you provide in the app.config.ts meta object. For example, if you set a specific title in meta, it will also be used for the og:title tag. If you need more specific or custom values for OG tags, define them separately or see the local SEO setup section below.

Schema.org

As you may have noticed, DocLayer uses the Nuxt Schema.org Module to manage the Schema.org graph. This means that some schema data is automatically generated and handled for you (remaining unchanged), while other parts can be customized either globally or on a per-page basis.

By default two objects for schema.org graph will be generated. The first of them is a global entry, automatically defined for the entire application. Its @type is set to WebSite, which is the default for the global schema graph representing your app. The name field is populated from your app name in the package.json file, while the url is taken from the site property in your nuxt.config.ts file. To easily manage that value, you can set the DL_META_DOMAIN environment variable to update it as needed.

<head>  <script type="application/ld+json" data-nuxt-schema-org="true" data-hid="schema-org-graph">    {      "@context": "https://schema.org",      "@graph": [        {          "@id": "https://doclayer.dev/#website",          "@type": "WebSite",          "name": "@vuehouse/dl-boilerplate",          "url": "https://doclayer.dev/"        },        // the rest of the graph      ]    }  </script></head>

The second object is always responsible for defining the graph entry for a specific page and will be of type WebPage. The name and description values are automatically generated based on your page's metadata. The inLanguage and publisher values are inherited from the global setup defined in your app.config.ts file. The rest of the pregenerated data should not be changed. If you need to customize any of this per page, you can do so using the local setup, which is explained below.

<head>  <script type="application/ld+json" data-nuxt-schema-org="true" data-hid="schema-org-graph">    {      "@context": "https://schema.org",      "@graph": [        // the rest of the graph        {          "@id": "https://doclayer.dev/docs/guidelines/defining-metadata#webpage",          "@type": "WebPage",          "description": "Learn on how to define metadata for your application",          "inLanguage": "en",          "name": "Defining Metadata",          "url": "https://doclayer.dev/docs/guidelines/defining-metadata",          "publisher": {            "@type": "Organization",            "name": "vue.house",            "url": "https://vue.house"          }        }      ]    }  </script></head>

Local metadata (page-based)

DocLayer also allows you to customize metadata for individual content pages. You can do this by adding metadata in the Frontmatter section of each page. To avoid conflicts with the default Nuxt Content setup and the native seo data, DocLayer introduces two additional objects: _seo and _schemaOrg. These objects let you clearly separate and customize SEO and Schema.org data for each page.

Defining your metadata correctly in the frontmatter is essential. Keep in mind that different blocks may be interpreted in specific ways, so clarity is important. Below, you'll find examples of how to set up SEO and Schema.org data. As a general rule, refer to the content schema used for your collections data model to ensure consistency.

Content schema objects are flat and do not contain nested structures, making it straightforward to define. In your content .md (Markdown) file, use Frontmatter with dedicated _seo keys, like this:

---title: Your page titledescription: Your page description_seo:  author: yourdomain.com  keywords: your, custom, keywords  robots: nofollow, noindex  'og:title': Your Open Graph title  'og:description': Your Open Graph description---

And the _schemaOrg keys as follow:

---title: Your page titledescription: Your page description_schemaOrg:  url: yourdomain.com/path/to/page  name: Your page title here  description: Your page description  inLanguage: de---

Remember that other elements are distributed globally, and there's no need to define them for each page separately.