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

Using blog and tags plugins in combination results in wrong links to Blog index #5952

Closed
4 tasks done
vedranmiletic opened this issue Sep 3, 2023 · 13 comments
Closed
4 tasks done
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open

Comments

@vedranmiletic
Copy link
Contributor

vedranmiletic commented Sep 3, 2023

Context

No response

Bug description

When blog and tags plugins are enabled together, the links to Blog index will be rendered as linking to the last page of the index instead of the first page.

Related links

Reproduction

9.2.7-using-blog-and-tags-in-combination.zip

Steps to reproduce

  1. mkdocs serve
  2. observe that the link on the Home page points to the second page of the Blog index
  3. remove tags plugin configuration from plugins section in mkdocs.yml
  4. observe that the same link is now generated correctly

Browser

No response

Before submitting

@squidfunk squidfunk added the bug Issue reports a bug label Sep 3, 2023
@squidfunk
Copy link
Owner

Fixed in 84cb91b. I think I found all cases and refactored how paginated views are handled during rendering with a more resilient approach. The problem reported was not exclusive to the tags plugin, but also happened when you went to the second page of the archive, and then clicked on "Latest posts", also ending up on the last page.

@squidfunk squidfunk added the resolved Issue is resolved, yet unreleased if open label Sep 3, 2023
@vedranmiletic
Copy link
Contributor Author

This commit actually causes a regression, which in my case manifests as ERROR - Error building page 'blog/archive/2010.md': Page(title='2010', url='/blog/archive/2010/') is not in list. I will prepare a minimal example for that one.

@vedranmiletic
Copy link
Contributor Author

9.2.7-url-not-in-list-regression.zip

Note that I am not really using version 9.2.7 here, but the git master (and I have independently bisected the bad commit to 84cb91b). The error I get is:

INFO    -  Building documentation...
INFO    -  Cleaning site directory
ERROR   -  Error building page 'blog/archive/1990.md': Page(title='1990', url='/blog/archive/1990/') is not in list
Traceback (most recent call last):
  File "/usr/local/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/__main__.py", line 270, in serve_command
    serve.serve(**kwargs)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 86, in serve
    builder(config)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 67, in builder
    build(config, live_server=None if is_clean else server, dirty=is_dirty)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/commands/build.py", line 349, in build
    _build_page(
  File "/usr/local/lib/python3.9/site-packages/mkdocs/commands/build.py", line 222, in _build_page
    context = config.plugins.on_page_context(context, page=page, config=config, nav=nav)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/plugins.py", line 583, in on_page_context
    return self.run_event('page_context', context, page=page, config=config, nav=nav)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/plugins.py", line 507, in run_event
    result = method(item, **kwargs)
  File "/home/vedranmiletic/.local/lib/python3.9/site-packages/material/plugins/blog/plugin.py", line 347, in on_page_context
    items[items.index(view)] = page
ValueError: Page(title='1990', url='/blog/archive/1990/') is not in list

@squidfunk squidfunk removed the resolved Issue is resolved, yet unreleased if open label Sep 4, 2023
@squidfunk
Copy link
Owner

Thanks, looking into it.

@squidfunk
Copy link
Owner

Fixed in 682d176. Thanks again for testing and providing the minimal reproduction – it only happened with 3 pages or more. I've tested the head of master against all reproductions we received related to the blog and think that it's finally stable... until the next bug appears 😅 If you can confirm that it works for you, we can release it today with the other fixes.

@squidfunk squidfunk added the resolved Issue is resolved, yet unreleased if open label Sep 4, 2023
@vedranmiletic
Copy link
Contributor Author

If you can confirm that it works for you, we can release it today with the other fixes.

Unfortunately not, the original bug seems to be back, both on the test case and real-world sites. I made sure several times that I am using the right version. Can you check on your side?

@squidfunk
Copy link
Owner

squidfunk commented Sep 4, 2023

Yes, the bug is back. I only checked the links in the navigation and they were all correct. I'll take a look. This is so exceptionally tricky to get right in all possible constellations...

@squidfunk squidfunk removed the resolved Issue is resolved, yet unreleased if open label Sep 4, 2023
@squidfunk
Copy link
Owner

squidfunk commented Sep 4, 2023

... and the next attempt in fc566cf. The links should now all be correct, unless I'm missing something. I've also, again, made sure this didn't break URLs for previously fixed issues.

@squidfunk squidfunk added the resolved Issue is resolved, yet unreleased if open label Sep 4, 2023
@squidfunk
Copy link
Owner

@vedranmiletic when you find some time, it would be great if you could verify if your issue is now fixed. We're waiting with the next release until this issue is fixed, so it would be awesome if you could check if the problem is gone ☺️

@vedranmiletic
Copy link
Contributor Author

Sure, go ahead. The issue looks fixed to me now. Thanks!

There is another small unrelated issue with tags and navigation.sections, but I will report that separately tomorrow.

@squidfunk
Copy link
Owner

Thanks! Released as part of 9.2.8.

@L3V147H4N
Copy link

L3V147H4N commented Nov 24, 2023

hello @squidfunk
this is still happening for me, I just tested today.. However it happens even when I disable tags
im getting ValueError: View(title=[blank], url='/blog/') is not in list

I get this just by including the blog plugin

full trace:

Traceback (most recent call last):
  File "/Users/matusevichg/.pyenv/versions/3.9.13/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File "/Users/matusevichg/.pyenv/versions/3.9.13/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/Users/matusevichg/.pyenv/versions/3.9.13/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/Users/matusevichg/.pyenv/versions/3.9.13/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/matusevichg/.pyenv/versions/3.9.13/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/matusevichg/.pyenv/versions/3.9.13/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/Users/matusevichg/.pyenv/versions/3.9.13/lib/python3.9/site-packages/mkdocs/__main__.py", line 270, in serve_command
    serve.serve(**kwargs)
  File "/Users/matusevichg/.pyenv/versions/3.9.13/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 86, in serve
    builder(config)
  File "/Users/matusevichg/.pyenv/versions/3.9.13/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 67, in builder
    build(config, live_server=None if is_clean else server, dirty=is_dirty)
  File "/Users/matusevichg/.pyenv/versions/3.9.13/lib/python3.9/site-packages/mkdocs/commands/build.py", line 311, in build
    nav = config.plugins.on_nav(nav, config=config, files=files)
  File "/Users/matusevichg/.pyenv/versions/3.9.13/lib/python3.9/site-packages/mkdocs/plugins.py", line 536, in on_nav
    return self.run_event('nav', nav, config=config, files=files)
  File "/Users/matusevichg/.pyenv/versions/3.9.13/lib/python3.9/site-packages/mkdocs/plugins.py", line 507, in run_event
    result = method(item, **kwargs)
  File "/Users/matusevichg/.pyenv/versions/3.9.13/lib/python3.9/site-packages/material/plugins/blog/plugin.py", line 180, in on_nav
    items[items.index(page)] = self.blog
ValueError: View(title=[blank], url='/blog/') is not in list

@L3V147H4N
Copy link

@squidfunk nevermind the rushed questions.. I fixed it by including - Blog: './blog/index.md' in the nav configuration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open
Projects
None yet
Development

No branches or pull requests

3 participants