welpo / tabi

A modern Zola theme with search, multilingual support, optional JavaScript, a perfect Lighthouse score, and a focus on accessibility.
https://welpo.github.io/tabi/
MIT License
127 stars 38 forks source link

Removing multi-language support and customising themes #90

Closed sandman closed 1 year ago

sandman commented 1 year ago

First of all, thank you for this very nice and clean theme :+1:

I am trying to customise the theme in two ways:

  1. Removing the multi-language support: I did this by simply removing all the Markdown files with the ca and es extensions. This does not work and I get the below error:
    
    ~/website$ zola serve
    Building site...
    Checking all internal links with anchors.
    > Successfully checked 1 internal link(s) with anchors.
    -> Creating 10 pages (0 orphan) and 6 sections
    Error: Failed to serve the site
    Error: Failed to render section '/home/sandip/website/content/_index.es.md'
    Error: Reason: Failed to render 'index.html' (error happened in 'base.html').
    Error: Reason: Function call 'trans' failed
    Error: Reason: Failed to retrieve term translation
    Error: Reason: Translation key 'about' for language 'es' is missing

2 . **Create new templates:** I want to create a new template based on section.html which does not include the list of posts. I did that by modifying section.html as follows:
``` html
{% extends "base.html" %}

{% block main_content %}

<main>
    {% if section.extra.section_path -%}
    {% set extra_section = get_section(path=section.extra.section_path) %}
    {% endif -%}

    {%- if section.extra.header %}
    {{ macros_page_desc::page_desc(desc=section.extra.header, page=section) }}
    {% endif -%}

    <!-- <div class="list">
        <div>
            {{ macros_page_header::page_header(title=section.title) }}
        </div>

        {%- if paginator %}
        {%- set pages = paginator.pages -%}
        {% else %}
        {%- set pages = extra_section.pages -%}
        {% endif -%}

        {% set max = section.extra.max_posts | default(value=999999) %}
        {{ macros_list_posts::list_posts(posts=pages, max=max) }}
    </div> -->
</main>

<!-- {% if paginator %}
{{ macros_paginate::paginate() }}
{% endif %} -->

{% endblock main_content %}

Is this the best way to achieve what I want?


More generally, I would like to know how to go about customising tabi. I'm quite new to Rust and SSGs but looking to get my hands dirty. Thanks :pray:

welpo commented 1 year ago

Hi! Thanks for your kind comments. I'm glad you enjoy the theme.

Removing multilingual support

To remove multilingual support, two things are needed:

I just did this with a fresh clone of the theme, and I couldn't reproduce the error you shared. Can you verify you removed all files/config lines? Are you still having the issue?

Creating new templates

For your modification, that's one way to do it, certainly! If you're sure you'll never want to use the previous template, your method works. You could also create a new template, and use it on your _index.md by modifying the template = line (see the docs). Either way works.

Customising tabi

Building this theme was my first approach to the world of SSGs/Rust/Zola. Keep in mind the templates aren't actually written in Rust, but rather in the Tera template engine, which is very similar to Jinja2, Liquid and Twig.

I built this theme by cloning another one (shadharon) and slowly changing stuff to my liking. It wasn't easy at first, but it does get easier the more time you spend with it. I'd suggest three things:

Have fun!

sandman commented 1 year ago

Many thanks for taking the time to write such a clear and complete response @welpo !

I will experiment with Tera and customise/create new templates to extend tabi. Are you open to receiving Pull Requests?

sandman commented 1 year ago

I just read the Contributing Guidelines, no need to respond to my question :)