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

"All posts ->" in main page links to "blog/" is hardcoded, so dead link if other section was chosen for main page #292

Closed
Dalker opened this issue Apr 13, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@Dalker
Copy link
Contributor

Dalker commented Apr 13, 2024

Bug Report

Environment

Zola version: 0.18.0
tabi version or commit: d0dd37e

Expected Behavior

When section_path in the [extra] section of front-matter of main content _index.md is set, it should be used to generate the list of posts visible in the main (first) page of the site. If, furthermore, max_posts = 1 is set, the "All posts ->" link that is then generated below the single post (the last post) visible on the main page should also point to the same section chosen with section_path

Current Behavior

If max_posts is greater than or equal to 2, everything works fine. With max_posts = 1, "All posts ->" points to a possibly non-existing "blog" section.

A little investigation shows that the issue comes from
the templates/macros/list_posts.html file,
where "blog" is hard-coded, instead of using the section_path chosen by the user.

Step to Reproduce

Place the following in content/_index.md for a site in which there is no blog subdirectory (aka section):

[extra]
section_path = "some_existing_section/_index.md"
max_posts = 1
@Dalker Dalker added the bug Something isn't working label Apr 13, 2024
@welpo
Copy link
Owner

welpo commented Apr 14, 2024

Hi Daniel!

Thanks for reporting this bug.

Would you be interested in creating a PR for the fix?

@Dalker
Copy link
Contributor Author

Dalker commented Apr 14, 2024

Hello Óscar and first of all thanks for making your great theme publicly available!

I'd be happy to contribute if I can manage to sort out a general solution, but it doesn't seem to be so simple (for my personal use I just did a quickfix replacing one hard-coded section name by another).

The difficulty is that the list_posts macro must be made aware of the target section, e.g. passed as an extra argument, but some of its callers do not seem to have that information available, notably tags/single.html -- or at least not simply by the name section (I'm new to zola so I might be missing something here).

EDIT: never mind, I figured out how to fix at least the specific problem in a somewhat general way; will send a pull request a bit later when I get the time to tidy it up

@welpo
Copy link
Owner

welpo commented Apr 18, 2024

Thanks for the report and the fix!

@welpo welpo closed this as completed Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants