Generate multilingual site without translated index/section pages

Hi there,

I have an existing monolingual site that I’m adding another language (French) to. I would like only occasional individual single pages to be in that language, and I would like the index page and list pages not to be generated for that language. I’m currently using the file name to translate pages, not a directory.

Specifically:

  • Currently, /fr/ and /fr/posts/ are being generated, with the same content as the default English versions. I don’t want these URLs to be generated — I only want the one translated post I have to be generated at /fr/posts/abc.
  • I’d also like the language not to show up in the slug if possible (e.g. no /fr/posts/abc, just /posts/abc. From reading other forum posts I don’t think this is possible, but this would be a nice to have!

My current language config is:

languages:
  en:
    languageName: English
    weight: 1
    params:
      lang: en
  fr:
    languageName: Français
    weight: 2
    params:
      lang: fr
      disabledKinds: ["home", "section", "taxonomy", "404"]

However, I can still open /fr/ and /fr/posts, which I assumed wouldn’t be generated given the disabledKinds.

I also considered just handling these posts separately with a different template, but I’d like date displays to be localized, and as far as I can tell that’s only possible by setting the page’s language correctly.

Here’s a link to the project if it’s helpful.

Thank you!

regarding your first point:

you have a typo with disableKinds not disabled

and this is a toplevel key, so it should not be under params:

languages:
  en:
    languageName: English
    weight: 1
    params:
      lang: en
  fr:
    languageName: Français
    weight: 2
    disableKinds: ["home", "section", "taxonomy", "404"]
    params:
      lang: fr

Your site configuration file has several problems (misspellings, incorrect yaml structure, useless keys, deprecated keys, etc.). Use this instead:

baseURL: https://kewbi.sh/blog
title: Yours, Kewbish
defaultContentLanguage: en
theme: yk
disableKinds:
  - taxonomy
publishDir: docs
languages:
  en:
    languageCode: en-ES
    languageName: English
    weight: 1
  fr:
    languageCode: fr-FR
    languageName: Français
    weight: 2
    disableKinds:
      - home
      - section
      - taxonomy
      - "404"
outputs:
  home:
    - html
    - rss
  section:
    - html
params:
  cssLink: https://kewbi.sh/css/main.css
  fontLinks: |
    <link
      rel="preload"
      as="text/woff2"
      href="https://kewbi.sh/fonts/playfair-display-v30-latin-italic.woff2"
    />
    <link
      rel="preload"
      as="text/woff2"
      href="https://kewbi.sh/fonts/playfair-display-v30-latin-700.woff2"
    />
    <link
      rel="preload"
      as="text/woff2"
      href="https://kewbi.sh/fonts/source-sans-3-v8-latin-regular.woff2"
    />

Thank you both so much for the help!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.