Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mcjill
Copy link

@mcjill mcjill commented Jan 26, 2025

Pre-flight checklist

  • I have read the Contributing Guidelines on pull requests.
  • If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior.
  • If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.

Motivation

Test Plan

Test links

Deploy preview: https://deploy-preview-_____--docusaurus-2.netlify.app/

Related issues/PRs

@facebook-github-bot
Copy link
Contributor

Hi @mcjill!

Thank you for your pull request and welcome to our community.

Action Required

In 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.

Process

In 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 CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

Copy link

netlify bot commented Jan 26, 2025

[V2]

Built without sensitive environment variables

Name Link
🔨 Latest commit ebdbfc2
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/67958967dc33b6000848e51a
😎 Deploy Preview https://deploy-preview-10868--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO Report
/ 🔴 44 🟢 98 🟢 96 🟢 100 Report
/docs/installation 🟠 50 🟢 97 🟢 100 🟢 100 Report
/docs/category/getting-started 🟠 72 🟢 100 🟢 100 🟠 86 Report
/blog 🟠 66 🟢 96 🟢 100 🟠 86 Report
/blog/preparing-your-site-for-docusaurus-v3 🟠 64 🟢 92 🟢 100 🟢 100 Report
/blog/tags/release 🟠 61 🟢 96 🟢 100 🟠 86 Report
/blog/tags 🟠 73 🟢 100 🟢 100 🟠 86 Report

Copy link
Collaborator

@Josh-Cena Josh-Cena left a 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}
Copy link
Collaborator

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}
Copy link
Collaborator

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:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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:

Comment on lines +251 to +258
:::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

:::
Copy link
Collaborator

@Josh-Cena Josh-Cena Jan 26, 2025

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 -->
Copy link
Collaborator

@Josh-Cena Josh-Cena Jan 26, 2025

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}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this H3

Comment on lines +272 to +276
:::caution

Don't use canonical URLs across different language versions. Each language version should be treated as unique content.

:::
Copy link
Collaborator

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

Comment on lines +278 to +313
### 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',
},
},
},
};

Copy link
Collaborator

@Josh-Cena Josh-Cena Jan 26, 2025

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:

  1. Include region codes in the locale identifiers if applicable
  2. Translate meta tags (title, description) for each language
  3. Maintain consistent content structures across locales
  4. 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.

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Jan 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants