Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing multi-language support and customising themes #90

Closed
sandman opened this issue Jul 9, 2023 · 3 comments
Closed

Removing multi-language support and customising themes #90

sandman opened this issue Jul 9, 2023 · 3 comments

Comments

@sandman
Copy link
Contributor

sandman commented Jul 9, 2023

First of all, thank you for this very nice and clean theme 👍

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:

{% 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 🙏

@welpo
Copy link
Owner

welpo commented Jul 9, 2023

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

Removing multilingual support

To remove multilingual support, two things are needed:

  • Removing all *.es.* and *.ca.* files, including the various _index files.
  • Removing or commenting out these lines in config.toml.

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:

  • Look around the Tera documentation
  • Explore how other themes are built.
  • GPT-4 can be quite helpful, though a bit stubborn. You need to remind it Tera is not identical to Jinja, and give it context and, some times, the relevant part of the docs. It can really speed up the initial approach, in my experience.

Have fun!

@sandman
Copy link
Contributor Author

sandman commented Jul 10, 2023

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
Copy link
Contributor Author

sandman commented Jul 10, 2023

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

@sandman sandman closed this as completed Jul 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants