All articles
gatsby

Solved Gatsby error: Encountered duplicate defintitions for one or more documents: each document must have a unique name. Duplicated documents

Share this article

Share on LinkedIn Share on X (formerly Twitter)

Today when building a GatsbyJS site I got an error of 'Duplicated documents'. I got it when I ran gatsby build in my Git Bash terminal. Later I found the fix for this.

If you too got the same error, first look at this issue over gatsbyjs official repo, since that might help for some: https://github.com/gatsbyjs/gatsby/issues/11688

Solution in my case:

I struggled for some time with some tweaks, such as

  • [x] Renaming graphql queries, giving unique name for each
  • [x] Renaming files
  • [x] Cleaning public and cache directories

Later when ran the build command in the command prompt, the site is successfully build.

Tip: Try running gatsby build in another terminal


Comments