{% if 'jinja2.ext.i18n' not in JINJA_ENVIRONMENT.extensions and 'jinja2.ext.i18n' not in JINJA_EXTENSIONS %}
    {% macro _(msg) %}
        {{ msg % kwargs }}
    {% endmacro %}
{% endif %}

<!DOCTYPE html>
<html lang="{% block html_lang %}{{ DEFAULT_LANG }}{% endblock html_lang %}">

<!-- Head -->
<head>
    {% block head %}

        <!-- Required metadata tags -->
        <meta charset="utf-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="HandheldFriendly" content="True" />
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />

        <!-- Default metadata -->
        {% block meta %}
            <meta name="author" content="{{ AUTHOR }}" />
            <meta name="description" content="{{ SITEDESCRIPTION }}" />
        {% endblock %}

        <!-- Site Claim -->
        {% if CLAIM_GOOGLE %}
            {% include 'includes/claim_google.html' with context %}
        {% endif %}

        {% if CLAIM_BING %}
            {% include 'includes/claim_bing.html' with context %}
        {% endif %}

        <!-- Title -->
        <title>
            {% block title %}
                {{ SITETITLE }}
            {% endblock title %}
        </title>
        
        <!-- Icon -->
        <link rel="shortcut icon" href="{{ SITEURL }}/favicon.ico" type="image/x-icon">
        <link rel="icon" href="{{ SITEURL }}/favicon.ico" type="image/x-icon">

        <!-- Search engine -->
        {% if page in hidden_pages %}
            <meta name="robots" content="noindex, nofollow" />
        {% else %}
            <meta name="robots" content="{{ ROBOTS }}" />
        {% endif %}

        <!-- Feeds -->
        {% if FEED_ALL_ATOM %}
            <link href="{{ FEED_DOMAIN }}/{% if FEED_ALL_ATOM_URL %}{{ FEED_ALL_ATOM_URL }}{% else %}{{ FEED_ALL_ATOM }}{% endif %}" type="application/atom+xml" rel="alternate" title="{{ SITENAME }} Full Atom Feed" />
        {% endif %}

        {% if FEED_ALL_RSS %}
            <link href="{{ FEED_DOMAIN }}/{% if FEED_ALL_RSS_URL %}{{ FEED_ALL_RSS_URL }}{% else %}{{ FEED_ALL_RSS }}{% endif %}" type="application/rss+xml" rel="alternate" title="{{ SITENAME }} Full RSS Feed" />
        {% endif %}

        {% if FEED_ATOM %}
            <link href="{{ FEED_DOMAIN }}/{%if FEED_ATOM_URL %}{{ FEED_ATOM_URL }}{% else %}{{ FEED_ATOM }}{% endif %}" type="application/atom+xml" rel="alternate" title="{{ SITENAME }} Atom Feed" />
        {% endif %}

        {% if FEED_RSS %}
            <link href="{{ FEED_DOMAIN }}/{% if FEED_RSS_URL %}{{ FEED_RSS_URL }}{% else %}{{ FEED_RSS }}{% endif %}" type="application/rss+xml" rel="alternate" title="{{ SITENAME }} RSS Feed" />
        {% endif %}

        {% if CATEGORY_FEED_ATOM and category %}
            <link href="{{ FEED_DOMAIN }}/{% if CATEGORY_FEED_ATOM_URL %}{{ CATEGORY_FEED_ATOM_URL.format(slug=category.slug) }}{% else %}{{ CATEGORY_FEED_ATOM.format(slug=category.slug) }}{% endif %}" type="application/atom+xml" rel="alternate" title="{{ SITENAME }} Categories Atom Feed" />
        {% endif %}

        {% if CATEGORY_FEED_RSS and category %}
            <link href="{{ FEED_DOMAIN }}/{% if CATEGORY_FEED_RSS_URL %}{{ CATEGORY_FEED_RSS_URL.format(slug=category.slug) }}{% else %}{{ CATEGORY_FEED_RSS.format(slug=category.slug) }}{% endif %}" type="application/rss+xml" rel="alternate" title="{{ SITENAME }} Categories RSS Feed" />
        {% endif %}

        {% if TAG_FEED_ATOM and tag %}
            <link href="{{ FEED_DOMAIN }}/{% if TAG_FEED_ATOM_URL %}{{ TAG_FEED_ATOM_URL.format(slug=tag.slug) }}{% else %}{{ TAG_FEED_ATOM.format(slug=tag.slug) }}{% endif %}" type="application/atom+xml" rel="alternate" title="{{ SITENAME }} Tags Atom Feed" />
        {% endif %}

        {% if TAG_FEED_RSS and tag %}
            <link href="{{ FEED_DOMAIN }}/{% if TAG_FEED_RSS_URL %}{{ TAG_FEED_RSS_URL.format(slug=tag.slug) }}{% else %}{{ TAG_FEED_RSS.format(slug=tag.slug) }}{% endif %}" type="application/rss+xml" rel="alternate" title="{{ SITENAME }} Tags RSS Feed" />
        {% endif %}

        <!-- Styles -->
        <!--
        <link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/4.3.1/css/bootstrap.min.css">
        -->
        <link rel="stylesheet" href="{{ SITEURL }}/{{ THEME_STATIC_DIR }}/bootstrap/bootstrap.min.css">
        <!--
        <link rel="stylesheet" href="https://cdn.rawgit.com/afeld/bootstrap-toc/v1.0.1/dist/bootstrap-toc.min.css">
        -->
        {% if article and article.toc == 'show' %}
            <link rel="stylesheet" href="{{ SITEURL }}/{{ THEME_STATIC_DIR }}/extra/bootstrap-toc.min.css">
        {% endif %}
        <link rel="stylesheet" href="{{ SITEURL }}/{{ THEME_STATIC_DIR }}/pygment/friendly.min.css">
        <!--
        <link rel="stylesheet" href="{{ SITEURL }}/{{ THEME_STATIC_DIR }}/extra/admonition.min.css">
        -->
        {% if page_name == 'search' %}
            <link rel="stylesheet" href="{{ SITEURL }}/{{ THEME_STATIC_DIR }}/tipuesearch/tipuesearch.min.css">
        {% endif %}
        <link rel="stylesheet" href="{{ SITEURL }}/{{ THEME_STATIC_DIR }}/style.css">

        <!-- Google Analytics -->
        {% if GOOGLE_ANALYTICS %}
            {% include "include/ga.html" %}
        {% endif %}

        <!-- Google Global Site Tag -->
        {% if GOOGLE_SITE_TAG %}
            {% include "include/gtag.html" %}
        {% endif %}

        <!-- Google Tag Manager -->
        {% if GOOGLE_TAG_MANAGER %}
            {% include "include/gtm.html" %}
        {% endif %}

        <!-- Google Adsense -->
        {% if GOOGLE_ADSENSE %}
            <script data-ad-client="{{ GOOGLE_ADSENSE.id }}" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
        {% endif %}

        <!-- Heap Analytic -->
        {% if HEAP_ANALYTICS %}
            {% include "include/ha.html" %}
        {% endif %}

        <!-- Piwik Tracking -->
        {% if PIWIK_SITE_ID and PIWIK_URL %}
            {% include "include/piwik.html" %}
        {% endif %}

        <!-- Matomo Tracking -->
        {% if MATOMO_SITENAME %}
            {% include "include/matomo.html" %}
        {% endif %}

    {% endblock head %}
</head>

<!-- Body -->
<body class="d-flex flex-column" data-spy="scroll" data-target="#toc" data-offset="0" style="position: relative;">
    <!-- Top anchor -->
    <a href="#" id="backToTop" style="display: none; z-index: 1;" title="Back to top"><span></span></a>

    <!-- Google tag manager -->
    {% if GOOGLE_TAG_MANAGER %}
        {% include "include/gtm_noscript.html" %}
    {% endif %}

    <!-- Navigation -->
    <nav class="flex-shrink-0 navbar navbar-expand-md navbar-expand-lg navbar-dark bg-dark text-light shadow-sm">
        <!-- Logo -->
        <a class="navbar-brand" href="{{ SITEURL }}">{{ SITETITLE }}</a>

        <!-- Collapse button -->
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarMenu" aria-controls="navbarMenu" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon small"></span>
        </button>

        <!-- Collapsible content -->
        <div class="collapse navbar-collapse" id="navbarMenu">

            <!-- i18n subsites -->
            {% if extra_siteurls %}
            <div class="dropdown">
                <button type="button" class="btn dropdown-toggle" data-toggle="dropdown">
                    <svg class="nav-icon" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24">
                        <path d="M12.87 15.07l-2.54-2.51l.03-.03A17.52 17.52 0 0 0 14.07 6H17V4h-7V2H8v2H1v2h11.17C11.5 7.92 10.44 9.75 9 11.35C8.07 10.32 7.3 9.19 6.69 8h-2c.73 1.63 1.73 3.17 2.98 4.56l-5.09 5.02L4 19l5-5l3.11 3.11l.76-2.04M18.5 10h-2L12 22h2l1.12-3h4.75L21 22h2l-4.5-12m-2.62 7l1.62-4.33L19.12 17h-3.24z" fill="#626262"/>
                    </svg>
                </button>
                <div class="dropdown-menu">
                    {% for lang, url in lang_siteurls.items() %}
                    <a class="dropdown-item {% if lang == DEFAULT_LANG %}active{% endif %}" href="{{ url }}/">{{ lang }}</a>
                    {% endfor %}
                </div>
            </div>
            {% endif %}

            <!-- Page links -->
            <ul class="navbar-nav mr-auto text-center">
                <li class="nav-item {% if page_name == 'index' %} active {% endif %}">                           
                    <a class="nav-link" href="{{ SITEURL }}">
                        <svg class="nav-icon" xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24">
                            <path d="M21 13v10h-6v-6h-6v6h-6v-10h-3l12-12 12 12h-3zm-1-5.907v-5.093h-3v2.093l3 3z" fill="currentColor"></path>
                        </svg>
                        Home <span class="sr-only">(current)</span>
                    </a>
                </li>
                <li class="nav-item {% if page_name == 'categories' %} active {% endif %}">
                    <a class="nav-link" href="{{ SITEURL }}/categories.html">
                        <svg class="nav-icon" xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24">
                            <path d="M16 6h-8v-6h8v6zm-8 12h-8v6h8v-6zm16 0h-8v6h8v-6zm-11-7v-3h-2v3h-8v5h2v-3h14v3h2v-5h-8z" fill="currentColor"></path>
                        </svg>
                        Categories
                    </a>
                </li>
                <li class="nav-item {% if page_name == 'tags' %} active {% endif %}">
                    <a class="nav-link" href="{{ SITEURL }}/tags.html">
                        <svg class="nav-icon" xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24">
                            <path d="M10.605 0h-10.605v10.609l13.391 13.391 10.609-10.604-13.395-13.396zm-4.191 6.414c-.781.781-2.046.781-2.829.001-.781-.783-.781-2.048 0-2.829.782-.782 2.048-.781 2.829-.001.782.782.781 2.047 0 2.829z" fill="currentColor"></path>
                        </svg>
                        Tags
                    </a>
                </li>
                <li class="nav-item {% if page_name == 'archives' %} active {% endif %}">
                    <a class="nav-link" href="{{ SITEURL }}/archives.html">
                        <svg class="nav-icon" xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24">
                            <path d="M1.8 9l-.8-4h22l-.8 4h-2.029l.39-2h-17.122l.414 2h-2.053zm18.575-6l.604-2h-17.979l.688 2h16.687zm3.625 8l-2 13h-20l-2-13h24zm-8 4c0-.552-.447-1-1-1h-6c-.553 0-1 .448-1 1s.447 1 1 1h6c.553 0 1-.448 1-1z" fill="currentColor"></path>
                        </svg>
                        Archives
                    </a>
                </li>
                <li class="nav-item {% if page and 'about' in page.title|lower %} active {% endif %}">
                    <a class="nav-link" href="{{ SITEURL }}/pages/about.html">
                        <svg class="nav-icon" xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24">
                            <path d="M20.822 18.096c-3.439-.794-6.64-1.49-5.09-4.418 4.72-8.912 1.251-13.678-3.732-13.678-5.082 0-8.464 4.949-3.732 13.678 1.597 2.945-1.725 3.641-5.09 4.418-3.073.71-3.188 2.236-3.178 4.904l.004 1h23.99l.004-.969c.012-2.688-.092-4.222-3.176-4.935z" fill="currentColor"></path>
                        </svg>
                        About
                    </a>
                </li>
            </ul>

            {% if page_name != 'search' %}
            <!-- Search form -->
            <form class="form-inline text-center" action="{{ SITEURL }}/search.html">
                <input class="form-control w-100 bg-dark text-light text-center border-0 p-2" type="text" name="q" pattern=".{3,}" title="At least 3 characters" required="" placeholder="Type here to search" aria-label="Search">
            </form>
            {% endif %}

            <!-- Social links -->
            <ul class="navbar-nav text-center">
                <li class="nav-item">
                    <a class="nav-link" href="{{ SOCIAL.facebook }}">
                        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
                            <title>Facebook</title>
                            <path d="M12 0c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm3 8h-1.35c-.538 0-.65.221-.65.778v1.222h2l-.209 2h-1.791v7h-3v-7h-2v-2h2v-2.308c0-1.769.931-2.692 3.029-2.692h1.971v3z" fill="currentColor"></path>
                        </svg>
                    </a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="{{ SOCIAL.github }}">
                        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
                            <title>Github</title>
                            <path d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z" fill="currentColor"></path>
                        </svg>
                    </a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="{{ SOCIAL.linkedin }}">
                        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
                            <title>Linkedin</title>
                            <path d="M12 0c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm-2 16h-2v-6h2v6zm-1-6.891c-.607 0-1.1-.496-1.1-1.109 0-.612.492-1.109 1.1-1.109s1.1.497 1.1 1.109c0 .613-.493 1.109-1.1 1.109zm8 6.891h-1.998v-2.861c0-1.881-2.002-1.722-2.002 0v2.861h-2v-6h2v1.093c.872-1.616 4-1.736 4 1.548v3.359z" fill="currentColor"></path>
                        </svg>
                    </a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="{{ SOCIAL.twitter }}">
                        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
                            <title>Twitter</title>
                            <path d="M12 0c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm6.066 9.645c.183 4.04-2.83 8.544-8.164 8.544-1.622 0-3.131-.476-4.402-1.291 1.524.18 3.045-.244 4.252-1.189-1.256-.023-2.317-.854-2.684-1.995.451.086.895.061 1.298-.049-1.381-.278-2.335-1.522-2.304-2.853.388.215.83.344 1.301.359-1.279-.855-1.641-2.544-.889-3.835 1.416 1.738 3.533 2.881 5.92 3.001-.419-1.796.944-3.527 2.799-3.527.825 0 1.572.349 2.096.907.654-.128 1.27-.368 1.824-.697-.215.671-.67 1.233-1.263 1.589.581-.07 1.135-.224 1.649-.453-.384.578-.87 1.084-1.433 1.489z" fill="currentColor"></path>
                        </svg>
                    </a>
                </li>
            </ul>
        </div>
    </nav>

    <!-- Full page -->
    <div class="flex-shrink-0 flex-grow-1">
    {% block page %}

        <!-- Header -->
        <header class="bg-dark text-light shadow-sm pt-3 pb-2">
            {% block header %}{% endblock header %}
        </header>

        <!-- Main -->
        <main class="py-3">
            {% block main %}
                <div class="container">
                    <!-- Sharing -->
                    {% block add_this %}
                    {% if ADD_THIS_ID and (page_name or page or article) %}
                        <div class="text-right mb-2 small" style="height: 26px">
                            <div class="addthis_inline_share_toolbox"></div>
                        </div>
                    {% endif %}
                    {% endblock add_this %}

                    <!-- Content -->
                    {% block content %}
                    {% endblock content %}
                </div>
            {% endblock main %}
        </main>

    {% endblock page %}
    </div>

    <!-- Footer -->
    <footer class="flex-shrink-0 bg-dark text-light small py-1">
        <div class="container text-center">
            &copy; {{ COPYRIGHT_YEAR }} <a href="{{ SITEURL}}">{{ SITENAME }}</a> by <a href="{{ SITEURL }}/pages/about.html">{{ AUTHOR }}</a>. Powered by <a href="http://getpelican.com">Pelican</a>, <a href="http://python.org">Python</a>, <a href="https://getbootstrap.com">Bootstrap 4</a><br>
            <!-- Do not remove below license sentence -->
            License: <a href="https://spdx.org/licenses/CC-BY-4.0.html">CC-BY-4.0</a>, based on <a href="https://github.com/vuquangtrong/simplify-theme">Simplify Bootstrap Theme</a>
        </div>
    </footer>

    <!-- Scripts -->
    <!--
    <script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.4.1.min.js"></script>
    -->
    <script type="text/javascript" src="{{ SITEURL }}/{{ THEME_STATIC_DIR }}/jquery/jquery-3.4.1.min.js"></script>
    <!--
    <script src="https://ajax.aspnetcdn.com/ajax/bootstrap/4.3.1/bootstrap.min.js"></script>
    -->
    <script type="text/javascript" src="{{ SITEURL }}/{{ THEME_STATIC_DIR }}/bootstrap/bootstrap.min.js"></script>
    <!--
    <script src="https://cdn.rawgit.com/afeld/bootstrap-toc/v1.0.1/dist/bootstrap-toc.min.js"></script>
    -->
    {% if article and article.toc == 'show' %}
        <script type="text/javascript" src="{{ SITEURL }}/{{ THEME_STATIC_DIR }}/extra/bootstrap-toc.min.js"></script>
    {% endif %}
    {% if page_name == 'search' %}
        <script type="text/javascript" src="{{ SITEURL }}/{{ THEME_STATIC_DIR }}/tipuesearch/tipuesearch.min.js"></script>
        <script type="text/javascript" src="{{ SITEURL }}/{{ THEME_STATIC_DIR }}/tipuesearch/tipuesearch.cfg.js"></script>
        <script src="{{ SITEURL }}//tipuesearch_content.js"></script>
        <script>
            $(document).ready(function() {
                 $('#tipue_search_input').tipuesearch();
            });
        </script>
    {% endif %}
    <script type="text/javascript" src="{{ SITEURL }}/{{ THEME_STATIC_DIR }}/style.js"></script>

    <!-- Sharing -->
    {% if ADD_THIS_ID and (page_name or page or article) %}
        <script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid={{ ADD_THIS_ID }}"></script>
    {% endif %}

    <!-- JSON LD -->
    {% block jsonld %}
        {% if article %}
            {% include "include/jsonld_article.html" %}
        {% else %}
            {% include "include/jsonld.html" %}
        {% endif %}
    {% endblock jsonld %}

    <!-- Disqus count -->
    {% block disqus_count %}
    {% endblock disqus_count %}
</body>

</html>
