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.53k stars 945 forks source link

Question: How to organize news feed items? #2513

Open dubrowgn opened 4 months ago

dubrowgn commented 4 months ago

I'm working on porting my old PHP/SQL site to zola, and I really like the simplicity and speed so far. One thing I haven't figured out yet though, is how to handle/organize "sub-page" sized content. The root index of my site has a "news feed" (see https://dubrowgn.com). The data for these look a lot like a page, but several are rendered together in a paginated fashion. I don't want each one rendered in its own page.

What I tried is creating pages under content/news, and just rendering them via content/news/_index.md. The rendered output looks like what I want, but I want the content to show up as the root index (e.g. https://dubrowgn.com, not https://dubrowgn.com/news). I can't figure out how to do this without breaking the rest of the site. The section logic tries to include all the site contents instead of just stuff under content/news. I also can't figure out how to prevent the individual news items themselves from rendering (e.g. no https://dubrowgn.com/news/foo/index.html). I looked at using ignore_contents in config.toml, but then the content disappears completely. I tried setting render = false on the news items, but that didn't work either.

Another idea I had was to just call get_section(path="news/_index.md"), but I can't figure out how to do pagination with that. It also still tries to render the individual news item pages.

The only other potential solution I see is to (ab)use taxonomies somehow, but I would prefer not to have to manually "tag" all my news items. It still doesn't prevent rendering of individual news item pages either.

I've spent enough time at this point I figured maybe I should just ask. What's the best way to handle "sub-page" content in zola? Ideally, something that's nice to organize/maintain, doesn't render individual pages, handles pagination, and can be rendered to the site's root index.

Thanks!

nwj commented 1 week ago

I think I have a similar use case and have also not figured out how to achieve this.

The general requirements are:

My specific for this is for a "/now" page (the section) that includes the full text of periodic updates (the pages). But I don't need or want the updates themselves to also have their own unique url.

My impression is that Zola doesn't support this, but perhaps someone here knows better?

Keats commented 1 week ago

Would making the subsections transparent with render = false for the pages work?

nwj commented 1 week ago

I tried something like that where I set render = false on each of the pages and then tried to build my section page this way:

{% for page in section.pages %}
  {{ page.content }}
{% endfor %}

But section.pages was empty in that case, I guess since render = false makes it so that the section doesn't include them in pages?

Regardless, I've kind of decided it's mostly fine to have each of these pages get their own unique url and I just won't link to them. Worst case it just means that they can be referred to individually by url even if that's not something I'm likely to need to do.

Keats commented 1 week ago

There is https://github.com/getzola/zola/pull/2585 that could solve that issue