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

Have root being a page and not a section #2553

Closed
jbirnick opened this issue Jun 27, 2024 · 1 comment
Closed

Have root being a page and not a section #2553

jbirnick opened this issue Jun 27, 2024 · 1 comment

Comments

@jbirnick
Copy link

jbirnick commented Jun 27, 2024

I'm currently porting my website https://jbirnick.net to Zola.

It consists of 4 main pages: About, Blog, Conferences, Links. The latter three are available under respective sub URLs, i.e.:

Blog: https://jbirnick.net/posts/
Conferences: https://jbirnick.net/conferences/
Links: https://jbirnick.net/links/

However, the "About" page is available directly under https://jbirnick.net/ and this is how I want it. (No redirect, the root should just be the "About" page.)

How can I implement this behavior in Zola? Because it forces me to make the root a section and not a page... So I had two ideas of solving that:

  1. Just put my content for "About" in the section _index.html and use the frontmatter template = "page.html". However, I don't like this, because it is semantically incorrect. I don't want "About" to be a section, it's a page. For example, I can't use the same page-specific frontmatter then, such as updated. In fact, it might not even work, because my page.html template might use the page-specific frontmatter, which will result in an error when called with a section.

  2. Make _index.html essentially empty with render = false, put "About" in about.md and somehow tell Zola that it should be mapped to the root path. However, I don't see a way to do this, as only the slug part of the path can be set, right?

Any help is greatly appreciated.

Sidequestion: Why is every SSG forcing me into the difference of "sections" and "pages" and forces the root to be a section? I somehow get it for Hugo because it partially uses paths for "semantics", in the sense that for example also templates are chosen by path. However, I thought Zola is more un-opinionated. For example, templates are not chosen by path anyways, but have to be specified in the frontmatter. EXCEPT the difference between section and page, for which the path is used, and where some things are enforced. Why? Why not eliminate the difference, have just one concept of page, and if the user wants to make a page which lists all subpages then they can make a specific template for that and call template = "list.html" or so.

@jbirnick jbirnick changed the title Have home page being a page and not a section Have root being a page and not a section Jun 27, 2024
@Keats
Copy link
Collaborator

Keats commented Jun 27, 2024

I would put the About content in _index.md and change its template to be page.html with a small

{% if section %}
{% set page = section %}
{% endif %}

but as you mentioned it's not going to cover cases where fields are not present for sections.

Sidequestion

I found that there 2 sets of people: some that like separating them and some that don't. There is https://zola.discourse.group/t/proposal-deprecate-sections/1968 to potentially unify them but that's not something that will be done soonish.

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