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

Rule in PAGINATION_PATTERNS for custom last page location breaks category links for categories with few posts #3307

Open
2 tasks done
sonologic opened this issue May 28, 2024 · 0 comments
Labels

Comments

@sonologic
Copy link

  • I have read the Filing Issues and subsequent “How to Get Help” sections of the documentation.
  • I have searched the issues (including closed ones) and believe that this is not a duplicate.

Issue

When using PAGINATION_PATTERNS, one can provide rules to change the url/file location of the pages generated for pagination. It is possible to specify a rule for the first page and for the last page. If there is only one page in a particular pagination, that page will be both the first and the last. The logic will apply the rule for the last page in this case, which breaks category links.

As an example, I have a category 'commentary' and have defined the following pagination settings:

DEFAULT_PAGINATION = 10
PAGINATION_PATTERNS = (
  (-1, '{name}last{extension}', '{name}last{extension}'),
  (1, '{name}{extension}', '{name}{extension}'),
  (2, '{name}{number}{extension}', '{name}{number}{extension}'),
)

There are only 4 articles in the 'commentary' category. The only file generated for the 'commentary' category is output/category/commentarylast.html.

Now, when linking to the 'commentary' category from a template using the code from the built-in simple theme:

<a href="{{ SITEURL }}/{{ cat.url }}" {% if cat==category %} aria-current="page" ={% endif %}>{{ cat|lower}}</a>

a link will be generated to category/commentary.html, which does not exist.

I think the solution is to change the rule selection logic, so that in case of only one page, the rule for first page is used instead of the rule for last page. I can make an MR for that, but only if you folks think that my issue actually is a bug and that my intended fix is indeed the way forward.

@sonologic sonologic added the bug label May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant