Set lang variable in base template

This commit is contained in:
pmoreno.rodriguez 2023-08-13 12:52:30 +02:00
parent 7b978aab42
commit b10473be0e
2 changed files with 6 additions and 6 deletions

6
templates/partials/base.html.twig Normal file → Executable file
View file

@ -2,7 +2,9 @@
{% set theme_config = attribute(config.themes, config.system.pages.theme) %}
{% set compress = theme_var('production-mode') ? '.min.css' : '.css' %}
{% set favicon = theme_config.favicon ? theme_config.favicon|first : { type:'image/png', path: url('theme://images/favicon.png') } %}
{% set new_base_url = base_url_absolute ~ theme_config.blog_page %}
{# Set site language #}
{% set lang = grav.language.getActive ?: grav.config.site.default_lang %}
{# Define if sidebar is shown in the page #}
{% set show_sidebar = header_var('show_sidebar')|defined(false) %}
@ -18,7 +20,7 @@
{% set subtitle = page.header.subtitle|raw %}
<!DOCTYPE html>
<html lang="{{ grav.language.getActive ?: grav.config.site.default_lang }}">
<html lang="{{ lang }}">
<head>
{% block head deferred %}
<title>{% if page.title %}{{ page.title|e('html') }} | {% endif %}{{ site.title|e('html') }}</title>

View file

@ -1,5 +1,3 @@
{# Set site language #}
{% set lang = grav.language.getActive ?: grav.config.site.default_lang %}
{# For SEO purposes, we avoid displaying more than one H1 tag. #}
{% set Htag = listing ? 'h2' : 'h1' %}
@ -51,7 +49,7 @@
{% endif %}
{% if author %}
<span itemprop="author" itemscope itemtype="http://schema.org/Person"/>
<a {% if page.taxonomy.author %}href="{{ base_url }}/author{{ config.system.param_sep }}{{ author }}" itemprop="url" {% endif %}class="author" aria-label="{{ author }}" rel="nofollow">
<a {% if page.taxonomy.author %}href="{{ blog.url }}/author{{ config.system.param_sep }}{{ author }}" itemprop="url" {% endif %}class="author" aria-label="{{ author }}" rel="nofollow">
<span class="name" rel="author">{{ author }}</span>
{% if avatar %}<img src="{{ avatar }}" alt="{{ author }}" />{% endif %}
</a>
@ -108,7 +106,7 @@
{% if page.taxonomy.tag %}
<ul class="stats">
{% for tag in page.taxonomy.tag %}
<li><a href="{{ base_url }}/tag{{ config.system.param_sep }}{{ tag }}" itemprop="keywords" rel="nofollow">{{ tag }}</a></li>
<li><a href="{{ blog.url }}/tag{{ config.system.param_sep }}{{ tag }}" itemprop="keywords" rel="nofollow">{{ tag }}</a></li>
{% endfor %}
</ul>
{% endif %}