Search code examples
reactjsinternationalizationgatsbycontentful

How to create indexable i18n content dynamically from a CMS in Gatsby


In my case I am trying to create SEO ready content from Contentful pulled into Gatsby. I've tried to integrate the community i18n plugin with the Contentful example here: https://github.com/mccrodp/gatsby-contentful-i18n/pull/1

I've seen the more general questions relating to i18n in Gatsby and the blog post Building i18n with Gatsby which does not use the community plugin, nor provide a linked repository example. However, I cannot understand how to integrate the community plugin gatsby-starter-default-i18n with dynamic content via a CMS, such as the Using Contentful Example.

I guess it boils down to how to manage layouts dynamically together with templates and the gatsby.node.js file, rather than the static example we have at the moment that does not use templates. An issue was raised here previously, on i18n plugin repo working with gatsby-source-contentful, but it seems inactive at the moment.

Any help greatly appreciated. I don't need to use the community plugin, just a SEO ready solution for indexed, dynamic i18n content paths. Thanks!


Solution

  • This involves using node_locale in createPages fn in gatsby.node.js to set the locale based paths. Then you can use this in combination with dynamic sources. For example, I have created starter repos for markdownRemark and Contentful: