Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Allow single-language pages #169

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

Conversation

ranbena
Copy link

@ranbena ranbena commented Jan 23, 2021

This is a PR to allow single-language pages.

The problem:
My site's intl is defined with 2 languages but a some pages are only in one language (for instance a page for a conference offered for English speakers only, therefore irrelevant to translate to additional locales).

But there is no way to indicate to the plugin that a certain page should "opt out" of all language page generation.

The solution:
Defining a page in a directory with the language name is easy and clear.
Here's an example:

// languages - en + es
|-- /src
    |-- /pages
        |-- foo.jsx      <-- normal: generates /foo, /en/foo, /es/foo
        |-- a/bar.jsx    <-- normal: generates /a/bar, /a/en/bar, a/es/bar
        |-- en/baz.jsx   <-- single language: generates en/baz only 🔥

Related to #152.

@ranbena
Copy link
Author

ranbena commented Jan 23, 2021

Notice, I'm already using this in production on a website of mine called citytree.

This is my pages folder.
You can see practical-ecology has both English and Hebrew.
While abracadabra is only in English (Hebrew yields 404 page).

@receter
Copy link

receter commented Feb 24, 2025

Interesting, I have the same issue. The solution I had in mind was a "shouldCreatePage" function in the settings that can decide based on the page if translations are create or not.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants