$pages->create() creating duplicate files in multi-language setup

I want to create a new page in a multi-language Kirby install. Default language is en.

$page->children()->create('unique-uid', 'template', [
            'title' => 'This is the page title'
]);

This creates two .txt files in the new page’s folder: template.txt and template.en.txt.

The view loads content from template.txt, but any subsequent logic applied to the page, for example $page->update(), applies the changes only to template.en.txt.

How can I create a page programmatically and only be left with the template.en.txt file?

I can confirm that this issue doesn’t happen with a fresh install of Kirby 2.1.1

So… stay tuned and I’ll try to figure out what I did to break my install :smile:

Narrowed it down. The duplicate file was being created by another operation, page('unique-id')->update().

Adding a second argument to the update() function, specifying the language, seems to fix the issue.

This code was being run within a route function, so perhaps the language wasn’t initialized yet.