Today I learned

Improving SEO with Gatsby Gitinfo

Edit this Post

When you are using GatsbyJS there is a really useful plugin to add git infomation to your pages.

The gatsby-transformer-gitinfo plugin enables to query for gitLogLatest fields like gitLogLatestEmail, gitLogLatestName and gitLogLatestDate.

{
  allMdx {
    edges {
      node {
        parent {
          ... on File {
            fields {
              gitLogLatestDate
              gitLogLatestAuthorEmail
              gitLogLatestAuthorName
            }
          }
        }
      }
    }
  }
}

This returns the following results:

{
  "data": {
    "allMdx": {
      "edges": [
        {
          "node": {
            "parent": {
              "fields": {
                "gitLogLatestDate": "2020-03-25 17:17:56 +0100",
                "gitLogLatestAuthorEmail": "marcokuehbauch@gmail.com",
                "gitLogLatestAuthorName": "Marco Kühbauch"
              }
            }
          }
        },
      ],
    },
  },
},

I found this particuarly useful when I wanted to add a "Last updated on" feature to my blog post.

I didn't want to add the updated date manually to every blog post I worked on. So using the git commit date for this is super helpful.

By adding a "Last updated on" feature I wanted to make sure that my content stays relevant and shows the users, if it's still usable information or if it's outdated.

A great sideeffect is, that it's also good for SEO to tell search engines, when your content was last updated and therefore rank it better.


I hope you enjoyed this post and learned something new. If you have any questions, feel free to reach out to me on Twitter or via Email .

If you want to support me, you can buy me a coffee. I would be very happy about it!

☕️ Buy me a coffee ☕️

I wish you a wonderful day! Marco