Skip to content

Overriding global meta description #112

Closed
@jaylinski

Description

@jaylinski

If I define a meta-description (frontmatter) in a page, it does not seem to override the meta-description defined in .vuepress/config.js

.vuepress/config.js

module.exports = {
  title: 'vuepress is awesome',
  description: 'this should be the default description for pages that do not define their own meta descriptions',
};

Example page

---
meta:
  - name: description
    content: my custom meta description
---

I would expect that my custom meta description is rendered, but the default description from .vuepress/config.js and the frontmatter-description are rendered.

These are the code parts that seem to be responsible for the page-meta processing:

'meta', { name: 'description', content: siteConfig.description }

const pageMeta = renderPageMeta(page.frontmatter && page.frontmatter.meta)

function renderPageMeta (meta) {

I'm not sure how to tackle this issue... maybe we could inject the global description into the page.frontmatter.meta object instead of the siteConfig.head object? Something like this:

// lib/prepare.js
const frontmatter = yaml.loadFront(content)
if (siteConfig.description && !frontmatter.meta.description) {
    frontmatter.meta.description = siteConfig.description
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions