Gatsby Head API with react-i18next
See original GitHub issuePreliminary Checks
- This issue is not a duplicate. Before opening a new issue, please search existing issues: https://github.com/gatsbyjs/gatsby/issues
- This issue is not a question, feature request, RFC, or anything other than a bug report. Please post those things in GitHub Discussions: https://github.com/gatsbyjs/gatsby/discussions
Summary
Hi,
I would like to know how to use i18n with Head API. I try this but it doesn’t work.
export const Head = () =>
{
const { t } = useTranslation();
return (<SEO
title={t('My title')}
/>)
}
I don’t see any explaination in the documentation about how to use i18n with Head API.
Steps to Resolve this Issue
- Add explaination about how to use i18n with Head API : https://www.gatsbyjs.com/docs/reference/built-in-components/gatsby-head/
Issue Analytics
- State:
- Created a year ago
- Reactions:4
- Comments:5 (2 by maintainers)
Top Results From Across the Web
gatsby-plugin-react-i18next
Easily translate your Gatsby website into multiple languages. Features. Seamless integration with react-i18next - a powerful internationalization framework for ...
Read more >Gatsby i18n: A Hands-on Guide | Phrase
Hit the ground running quickly with this Gatsby i18n tutorial and learn how to add internationalization support to your Gatsby project.
Read more >Implement i18n to a Gatsby site - Medium
In this article we will implement i18n (Internationalization) to a Gatsby site using react-intl and React context API, we will only cover ...
Read more >how to use i18n to gatsby? - Stack Overflow
import React from 'react'; import PropTypes from 'prop-types'; import { translate } from 'react-i18next'; import { Head } from ...
Read more >How to use Gatsby's Head API with MDX - Paul Scanlon
React Helmet. Historically the way to add indexable meta data to you Gatsby site's <head> element was to use a combination of react-helmet ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi!
At the moment you can’t use libraries that rely on React Context as we currently don’t wrap the Head API with these providers, see: https://github.com/gatsbyjs/gatsby/discussions/35841#discussioncomment-3258990
We have to make this change for Gatsby 5 as it’ll be a breaking change, but afterwards you’ll be able to place your providers there and then the information is available in the Head API.
So for now this is not possible unfortunately.
Hi! You can use a conditional inside Head extracting the language of the data props, and based on the result you launch one thing or another. it is not necessary to put the seo descriptions in the json, put them directly in the head