-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: add comprehensive i18n SEO guide #10868
base: main
Are you sure you want to change the base?
Conversation
Hi @mcjill! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
✅ [V2]Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
⚡️ Lighthouse report for the deploy preview of this PR
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree this is a good section to have, but the current audience is unclear.
|
||
When your Docusaurus site supports multiple languages, it's crucial to implement proper SEO practices to help search engines understand and serve the right content to users. Here's how to optimize your multilingual site: | ||
|
||
### Language Tags {#language-tags} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for these H3 headings; there isn't enough information under it for it to be sectioned. Each section is just a single paragraph, which is enough as a signpost for sectioning.
</html> | ||
``` | ||
|
||
### Hreflang Tags {#hreflang-tags} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
|
||
### Hreflang Tags {#hreflang-tags} | ||
|
||
Hreflang tags help search engines serve the correct language version to users. Docusaurus automatically generates these tags for all your language versions: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hreflang tags help search engines serve the correct language version to users. Docusaurus automatically generates these tags for all your language versions: | |
`<link hreflang>` tags help search engines serve the correct language version to users. Docusaurus automatically generates these tags for all your language versions: |
:::tip Understanding hreflang | ||
|
||
- Use `hreflang` to indicate language variants of a page | ||
- Include all language versions, including the current page | ||
- Add `x-default` for pages without targeting | ||
- Always use full URLs in `href` attributes | ||
|
||
::: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove; this doesn't pertain to Docusaurus users. We already handle all of these by default.
Hreflang tags help search engines serve the correct language version to users. Docusaurus automatically generates these tags for all your language versions: | ||
|
||
```html | ||
<!-- For your English pages --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no information in this code block that indicates that it's an "English page", so including this confuses readers.
|
||
::: | ||
|
||
### Canonical URLs {#i18n-canonical} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this H3
:::caution | ||
|
||
Don't use canonical URLs across different language versions. Each language version should be treated as unique content. | ||
|
||
::: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't pertain to Docusaurus
### Best Practices {#i18n-seo-best-practices} | ||
|
||
1. **URL Structure** | ||
- Use clear language indicators in URLs (e.g., `/en/`, `/es/`) | ||
- Keep URL structure consistent across languages | ||
- Consider using country codes for region-specific content (e.g., `/en-us/`, `/es-mx/`) | ||
|
||
2. **Content Translation** | ||
- Translate meta tags (title, description) for each language | ||
- Maintain consistent heading structure across translations | ||
- Adapt content for cultural differences when necessary | ||
|
||
3. **Default Language** | ||
- Set a clear default language in your configuration | ||
- Use `x-default` for language selection pages | ||
- Consider your primary audience when choosing defaults | ||
|
||
4. **Technical Implementation** | ||
```js title="docusaurus.config.js" | ||
export default { | ||
i18n: { | ||
defaultLocale: 'en', | ||
locales: ['en', 'es', 'fr'], | ||
localeConfigs: { | ||
en: { | ||
htmlLang: 'en', | ||
path: 'en', | ||
}, | ||
es: { | ||
htmlLang: 'es', | ||
path: 'es', | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs a rewrite. What's the purpose? I don't see any coherent structure here. Is it educating Docusaurus users how to implement better SEO for their own content using our framework (which is the goal), or is it advertising how Docusaurus handles everything under the hood (which is fine but unnecessary), or is it general education material about how to do SEO in a website (which wouldn't be topical for us)?
I am assuming it's for the first purpose, in which case you just need to mention the following:
- Include region codes in the locale identifiers if applicable
- Translate meta tags (title, description) for each language
- Maintain consistent content structures across locales
- Adapt content for cultural differences when necessary, and pointing to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl as a possible API to use for custom React components that render data.
And then point to our Internationalization docs for anything specific about using i18n in Docusaurus.
Pre-flight checklist
Motivation
Test Plan
Test links
Deploy preview: https://deploy-preview-_____--docusaurus-2.netlify.app/
Related issues/PRs