Flobin
Flobin

Reputation: 708

Pelican i18n subsites menu items override

I am building a static site with Pelican and the i18n subsites plugin.

The way I understand it, you can override settings in pelicanconf.py with this plugin, but I don’t think the way I did it is working.

Pelicanconf.py:

I18N_SUBSITES = {
    'nl': {
        'SITENAME': 'Robin Berghuijs Design',
        'INDEX_SAVE_AS': 'nieuws.html',
        'MENUITEMS': [
            ('Nieuws','nieuws.html'),
        ],
    },
    'en': {
        'SITENAME': 'Robin Berghuijs Design',
        'INDEX_SAVE_AS': 'news.html',
        'MENUITEMS': [
            ('News','news.html'),
        ],
    }
}

Index.html output:

<nav id="menu"><ul>
    <li><a href="./pages/contact.html">Contact</a></li>
</ul></nav><!-- /#menu -->

base.html template:

    {% for title, link in MENUITEMS %}
        <li><a href="{{ link }}">{{ title }}</a></li>
    {% endfor %}

I get no errors upon site generation. More detail here.

Running pelican with --debug gives this.

Upvotes: 2

Views: 214

Answers (2)

tuomastik
tuomastik

Reputation: 4906

I had the same issue and the same understanding of how the settings could be overwritten, but ended up using this "workaround" where DEFAULT_LANG gets value "nl" or "en" based on the localized page that Pelican is currently generating.

{% for page_title, page_link in I18N_SUBSITES[DEFAULT_LANG].MENUITEMS %}
    <li><a href="{{ page_link }}">{{ page_title }}</a></li>
{% endfor %}

Upvotes: 0

Flobin
Flobin

Reputation: 708

As it turns out, the i18n subsites plugin was creating two new sites, with the old one left in the output folder. So there was a site in output/, one in output/nl/, and one in output/en/. Adding DELETE_OUTPUT_DIRECTORY = True and 'OUTPUT_PATH': '', to the Dutch i18n subsites settings solved the issue.

Upvotes: 1

Related Questions