Add or import languages in a Sitecore-first JSS Next.js app

Version: 22.x

When working Sitecore-first in a project created with the Sitecore Containers template for Next.js, you might need to deploy new languages or import previously deployed languages and items in that language.

Add a language to the Sitecore-first Next.js project

The Next.js JSS application created when you create your development project using the Sitecore Containers template for Next.js has examples for multilingual Styleguide components that have language routes. For the language routes to work, you must add the language for those routes to Sitecore.

To add a new language to the Sitecore instance in the Sitecore-first Next.js project:

  1. Add the language to /sitecore/system/Languages. The Next.js sample app uses Danish (da-DK).

  2. Deploy the items in that language:

    RequestResponse
    jss deploy items --language=da-DK --includeContent --includeDictionary
    
  3. Publish the language:

    RequestResponse
    dotnet sitecore publish

Import a deployed language to your serialized items

To import items for a previously deployed language into the serialized items of your containerized Sitecore-first project:

  1. In the file src/InitItems.module.json in your containerized project, add a serialization configuration for languages. For example:

    RequestResponse
    {
           "name": "languages",
           "path": "/sitecore/system/Languages",
           "scope": "descendantsOnly",
           "rules": [
               {
                   "path": "/en",
                   "scope": "ignored"
               }
           ]
       }
  2. In a terminal, in the root directory of the project, run the following command:

    RequestResponse
    dotnet sitecore ser pull

Do you have some feedback for us?

If you have suggestions for improving this article,