Comments (6)
Good point, I'll fix that
from zola.
That's actually quite tricky!
We need to render pages from the render_sections
so we can sort/populate prev/next correctly but we also want to render correctly prev/next for the index page if we don't have a section for content like my site.
So we would have 2 spots to render a page: render_section
and build_pages
. render_section
needs to be called first and build_pages
can check whether the file already exists and if not, populate with "global" previous/next and render the page.
The index page does seem a bit too magical looking at the above, I'll need to think a bit more on what would be the best behaviour for it. Maybe I was thinking too much about how Hugo does it while it could be done better.
from zola.
(writing down some thoughts)
So after some thoughts the problem boils down to the differences between a simple case (blog + about page) and more complex cases such as blog + landing page + knowledge base for example. Your blog is a bit towards the simple case where you have a few sections that you want to order separately but never together. It's more a documentation site in this regard.
I can't think of a single case where you would to mix sections automagically in the index page though.
A few solutions came to mind but after writing this only one didn't feel like a hack, let's take a simple case as example since this is where the confusion comes I think.
content/
- _index.md
- one-blog-post.md
- another-blog-post.md
- pages/
- about.md
- projects.md
Make index a (almost) pure section
Which means it won't automatically get variables like pages
at all. The index will still get variables like sections
but it will only get pages directly next to the content/_index.md
. In the example, section.pages
in the landing page will contain one-blog-post
and another-blog-post
and a user would iterate like so:
{% for page in section.pages %}...{% endfor %}
The index section
may or may not be contained in the sections
variable passed to the template, I'm not convinced about the necessity of doing that yet.
Pages will be sorted by the index section depending on the sort_by
parameter and prev/next will always only apply inside a section only.
I think this approach solves most of the issue and will do what people expect to most of the time. It's not as straightforward as Hugo might be but I believe it's not that far in practice and removes ambiguity for the index page.
from zola.
The last question to solve for it to make sense is what to do with pages with no sections (orphan pages). Those should still be rendered but won't be listed in any section.pages
.
The easiest way would be to find make the list of pages in sections and compare those missing from the full list of pages and render the orphan pages after rendering all sections.
from zola.
Implementation is in #60 which should also fix what this issue is about!
I'll need to test it a bit more myself though.
from zola.
@phil-opp it should be working in master
Edit: also in 0.0.5 that was just released
from zola.
Related Issues (20)
- How to use sort_by to Sort taxonomies in taxonomy_list.html? HOT 6
- Sintax highlighting of `?Sized` rust code is invalid HOT 1
- Internal anchors can be added by templates HOT 1
- support treating standalone .html files as pages HOT 4
- JPEG XL support for image processing? HOT 5
- Improve documentation about enabling Sass
- `zola serve` with `--output-dir` stopped serving assets in v0.18.0 HOT 7
- PR Question - Docs Contributions HOT 6
- Incorrect Plist syntax: UnexpectedXmlCharactersExpectedElement (offset 56) HOT 2
- `zola serve` treats `_` and `-` as equivalent for static assets, other static web servers do not. HOT 1
- `resize_image` default compression parameters for PNG often make files larger HOT 1
- Excerpt separator not compatible with Hugo (or Jekyll), is `<!-- more -->` rather than `<!--more-->` HOT 2
- Shortcode markdown filter results in a superfluous newline at end HOT 2
- get_url generates http url during serve, even though base_url defines https HOT 3
- Feature request: Proper support for GitHub Codespaces / dev containers HOT 5
- Section links refer to permalink#section
- Search question: is it possible to set search weight per page HOT 1
- 0.18.0 `zola serve` requires restart to complete Getting Started Overview HOT 1
- Content from theme is not loaded? HOT 5
- Option to invalidate template cache after specified time
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zola.