Kirby

Html lang attribute missing

I have a kirby 3 project with 2 languages, DE and EN and the html lang attribute in the browser code is empty.

I tried already: Multi-language site and HTML lang tag but doesn’t solve the problem.

Default language DE and secondary language EN are activated in the panel and everything works.

Asking me if this declaration in the header snippet is correct or how to bring the lang code definition into this.

site/snippets/header.php:
<!doctype html>

Like in the example, but not $site but $kirby for Kirby 3

Thnx Sonja! this code solves the problem:

<html lang="<?php echo $kirby->language()->code() ?>">

Is there a way to generate the HTML’s lang attribute without running a mutli-language setup? I just set up a one-language multi-language setup because I don’t want to hardcode the language into the template and I found no way without introducing a language field for a page or to get the language of the #1 admin user.

If you want to make it customisable, you can set up a field in site.yml or add an option in your config.php.

2 Likes