How to Keep CreatedAt and UpdatedAt after Deploy in NuxtJS

Last updated at April 24, 2021

💬

If you using git, createdAt and updatedAt data for your content using @nuxt/content module will be always reset to deployment date in your live server.

This is because git does not file metadata.

We can use git history based on your commit date.

Install nuxt-content-git package from npm

nuxt-content-git is additional module for @nuxt/content that replaces or adds createdAt and updatedAt dates based on the git history.

bash
npm install nuxt-content-git --save

Configure nuxt-content-git in nuxt.config.js

Add nuxt-content-git to modules before @nuxt/content.

/nuxt.config.js
export default {
  // ...
  modules: [
      'nuxt-content-git',
      '@nuxt/content',
    ],
  // ...
}

Finish

Lets deploy and check createdAt and updatedAt date for your content.