question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to define article properties like meta tags for SEO?

See original GitHub issue

Hi!

I have developed a blog with nuxt and vue-meta with a database solution, so I ask for every meta tags for each page. But this git-based solution is very elegant and simple.

I would like to know which is the right mechanism for share meta info between content articles and component head method.

After reading nuxt/content docs I tried defining meta info like author near to title property like this:

// content/home.md
---
title: Home
author: Juan Manuel López Pazos
---

# Welcome to my blog

Then I load that info in asyncData method:

// views/_slug.vue
async asyncData ({ $content, params }) {
    const articles = await $content('articles').fetch()

    const path = params.slug ? `articles/${params.slug}` : 'home'
    const doc = await $content(path).fetch()

    return {
      articles,
      doc
    }
  },

And finally use doc.author property as author meta tag in head method:

// views/_slug.vue
head () {
  return {
    title: this.doc.title,
    meta: [
      {
        hid: 'author',
        name: 'author',
        content: this.doc.author
      }
    ]
  }
}

This solution works and the author meta tag is added to document. However I don’t know if this is the right and cleaner way.

In case that this solution is right, I think properties section in .md files can turned into a garbage. Is developer’s responsibility to keep it clean? Or is nuxt/content going to offer a more sophisticated mechanism for this stage?

Thank you so much.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
pablomurocommented, Dec 31, 2020

Hi guys, I found a “solution”, since we like to just read the data from the article variable you can use the ‘$data’ object from the ‘this’ vue instance

description: this.$data.article.description,
1reaction
jessequinncommented, Jul 19, 2020

@jackdomleo7 i also ran into this error with TS.

Read more comments on GitHub >

github_iconTop Results From Across the Web

A quick and easy guide to meta tags in SEO
Six meta tags to improve the optimization of your site · 1. Title tag · 2. Meta description · 3. Robots meta tag...
Read more >
8 Game Changing Meta Tags for SEO | Clutch.co
Meta tags for are HTML tags that describe your page content to search engines and website visitors. The meta tags appear only in...
Read more >
Meta Tags: What You Need To Know For SEO
Learn about how to use meta tags for SEO, including the page title and meta description tags. Best practices, implementation, and more.
Read more >
Meta Tags and Attributes that Google Supports | Documentation
Google supports both page-level meta tags and tag attributes. Explore a list of the special tags that Google Search can support.
Read more >
Meta Tags in SEO: the Ultimate Guide - ContentKing
By using meta tags, you can make sure browsers and search engines behave as you want them to, and display your content in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found