getzola / zola

A fast static site generator in a single binary with everything built-in. https://www.getzola.org
https://www.getzola.org
MIT License
13.63k stars 952 forks source link

Multilang index.md results in Error: We can't have a page called `index.md` in the same folder as an index section in #2370

Closed Toasterson closed 10 months ago

Toasterson commented 10 months ago

Bug Report

Environment

Zola version: 0.17.2 (Archlinux)

Expected Behavior

Site renders index page in multiple languages de and en default. with en placed at root and de under /de/

Current Behavior

Site fails to build with

Error: We can't have a page called `index.md` in the same folder as an index section in "/export/home/toast/workspace/web/atelierwegi/content"

Step to reproduce

The following is my content tree

.
├── config.toml
├── content
│   ├── de.md
│   ├── en.md
│   └── index.md
├── public
│   ├── elasticlunr.min.js
│   ├── search_index.de.js
│   ├── search_index.en.js
│   └── site.css
├── sass
├── static
│   └── site.css
├── templates
│   ├── base.html
│   ├── index.html
│   └── page.html
└── themes

7 directories, 12 files
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <title>Atelier Wegi</title>
    <link rel="stylesheet" href="/site.css">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>

<body>
    <section class="section">
        <div class="header">
            <div class="logo">
                <h2>Website</h2>
            </div>
            <div class="nav">
            </div>
        </div>
        <div class="container">
            {% block content %} {% endblock %}
        </div>
    </section>
</body>

</html>
{% extends "base.html" %}

{% block content %}
<h1 class="title">
  Fixed title
</h1>
<p>Index Page</p>
{% endblock content %}
{% extends "base.html" %}

{% block content %}
<div></div>
<div class="content">
  {{ page.content | safe }}
</div>
<div></div>
{% endblock content %}

Current Repo is here https://gitlab.com/Toasterson/atelierwegi

As soon as I place any index.md or _index.md file in the root this happens. I can work around it my manually adding the index.md content to the index.html or by making the browser auto switch to a fake language section by making a de.md and a en.md and place some javascript into the index.html to switch th page but it would be nice to have the index be markdownable aswell.

Keats commented 10 months ago

I can't access the repo, i get a 404

As for the issue, we auto-generate a _index.md for the root section (content/) as homepage if there isn't one. index.md is a reserved file name in Zola to indicate a page with colocated assets so it can't be used outside of that context. We should add it to the docs if it isn't mentioned.

Toasterson commented 10 months ago

Ah, gitlab defaults to private repos for me. Good to know. Made it visible no secrets in there.

I think I got confused with pages and language docs, yes. Especially since the quick start blog skips the index page and only adds the html. With _index I get the first page but I guess sections cannot be translated? So I can not get /en/ to show the english version by having _index.en.md I guess?

Toasterson commented 10 months ago

Looks like I got confused. With my current setup it works now.