How to Add Text to Your Tag Pages in Gridsome

September 11, 2020 · Updated January 23, 2021 · 2 min read
Printing Letters
Photo by Kristian Strand on Unsplash

This is part sixteen of a series on building a file-based blog from scratch with Gridsome. Find the full series here.

We have separate pages for our tags, great!

But they are all the same. How can we add text to the tag pages, so we can let our readers know more about them?

Here's a simple way.

We start by extending our gridsome.server.js:

module.exports = function (api) {
  api.loadSource(({ getCollection }) => {
    const posts = getCollection('BlogPost')

    const now = new Date() => {
      if (new Date( > now) {
        if (process.env.NODE_ENV === 'production') {
          posts.removeNode( // must remove by node id
        } else {
          node.title = `DRAFT: ${node.title}`

    // our tag descriptions
    const tagDescriptions = {
      backend: 'All about backend! The hottest backend frameworks for JS.',
      frontend: 'Mainly posts about Gridsome, the JAMstack framwork for Vue.js.',
      design: '"The alternative to good design is always bad design. There is no such thing as no design." -- Adam Judge, author',
      hipster: 'All about the newest tech gadgets.'

    // add descriptions to tag data nodes
    const tags = getCollection('Tag') => {
      if (tagDescriptions[]) {
        tag.description = tagDescriptions[]

The important parts are the tagDescriptions object with our descriptions, and the part after that where we load the Tag collection and iterate over the data nodes.

Now we can extend our src/templates/Tag.vue component:

    <h1 class="mb-5 text-2xl font-semibold text-gray-900 dark:text-gray-100">
      {{ $page.tag.title }}
      class="pb-2 mb-8 text-lg"
      {{ $page.tag.description }}

    <ul class="list-disc list-outside">
        v-for="post in $page.tag.belongsTo.edges"
        <g-link :to="post.node.path">
          {{ post.node.title }}{{ }}

query Tag ($id: ID!) {
  tag: tag (id: $id) {
    belongsTo {
      edges {
        node {
          ...on BlogPost {
            date (format: "MMMM D, Y")

export default {
  metaInfo () {
    return {
      title: 'Tag: ' + this.$page.tag.title

The two important parts here are the description property in the GraphQL query and the Vue-HTML block in the template that adds the tag's description if present:

<h2 v-if="$page.tag.description" class="pb-2 mb-8 text-lg" > {{ $page.tag.description }} </h2>

If you get an error that the description property does not exist on the tag query result, then you need to make sure that at least one of your tags has a description in the mapping above.

Now you can see the description on the tag page:

Gridsome tags page with description

Next part: Using Storybook

That’s it for this post on how to add an article series overview page to your Gridsome blog. In the next part of this series, we add Storybook to our blog.