Kick off your project with this internationalized personal blog website boilerplate.
Visit www.gatsby-starter-intl-blog.now.sh to see the starter live in action.
Deployment is made simple and fast thanks to providers like Vercel or Netlify. Click on one of the buttons below to deploy in seconds.
.
├── content # Markdown files used by Gatsby to generate pages
│ ├── en # Content translated to English langauge
│ └── [language-key] # Content translated to [language-key] language
├── src
│ ├── assets # Static assets (e.g. CSS and images)
│ ├── components # All React and Gatsby-friendly components
│ ├── hooks # React hooks for better reusability
│ ├── locales # Translations for UI components for every supported language
│ ├── pages # Pages that are generated by Gatsby
│ ├── templates # Templates used by Gatsby to generate pages
│ └── utils # Utility functions that are needed across the application
├── CHANGELOG.md
├── CONTRIBUTING.md
├── gatsby-config.js
├── gatsby-node.js
├── LICENSE
├── package.json
├── postcss.config.js
├── README.md
└── tailwind.config.js
This starter supports addition of new languages right out of the box.
Firstly, you will need to follow certain rules for internationalization to work correctly. Breaking any of the following rules may cause internationalization not to work properly if at all.
post_title
, post_category
and post_date
in frontmatter of article's MD filepost_category
field inside frontmatter consistent across all blog posts in the category's folderpost_date
field inside frontmatter consistent across all blog posts---
page_description: This is a super blog post 2 # Use for better SEO
post_title: Hello there
post_category: Reflections
post_date: "2020-04-05"
---
Suggestion: keep folders names of articles (blog posts titles in other words) and their categories in the default language (e.g. default language of the website in the example mentioned above would be English)
Note: it is not necessary to make a post translation immediately after writing a blog post in any of the supported languages
Replace [language-key]
with the actual language key that represents the language that is to be added.
Open gatsby-config.js file
Extend configuration of gatsby-plugin-intl
[language-key]
to options.languages
array[language-key]
to options.external.languageStrings
arrayExtend configuration of gatsby-source-filesystem by adding the following entry
{
resolve: `gatsby-source-filesystem`,
options: {
name: `[language-key]/blog`,
path: `${__dirname}/content/[language-key]/blog`,
},
Open locales folder and create a new [language-key].json
file with corresponding translations
Open content folder and create a new /[language-key]/blog/
folder (ideally with translated existing articles included)
Extend existing GraphQL queries in the hooks folder by adding the newly added language
Extend existing GraphQL page queries in post.js and category.js by adding the newly added language
You are done
Default language is selected at the very first load of the website if the browser language of a visitor does not match any of the supported languages or it cannot be read correctly. Execute the following steps in order to change it:
options.external.defaultLanguage
key with wanted language keyMake it fully yours by replacing defaults with your personal information. Firstly, open gatsby-config.js and change title
, siteUrl
and properties of author
object inside siteMetadata
object.
Replace default favicon.png file.
Replace default header_image.jpg file.
Set openToWork
to either true
or false
inside gatsby-config.js.
Check CONTRIBUTING.md in order to see how to contribute to this open-source project.
Check what is new but also the history of changes for this project in CHANGELOG.md.
This project is under the MIT license which is great! Read more inside LICENSE.