Search code examples
graphqlcontent-management-systemgatsbycontentfulcontentful-api

Contenful content displaying twice in GraphQL query


I'm learning gatsby and contentful to build a website but with when I query data from Contentful it displays the same content twice like below. what could be the reason?

enter image description here


Solution

  • I just had exactly same problem here for my gatsby+contentful project. I guessed you have two locales set up in Contentful and it will automatically displays all languages you gave to it. To avoid that, you can simply add a filter in your query:

    query { allContentfulBlogpost(filter: {node_locale: {eq: "en-US"}}) { edges { node { title node_locale } } } }
    

    If you see only English show in node_locale that means you success!