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

Instant loading and the project plugin language switcher don't work together #6582

Closed
4 tasks done
janvanveldhuizen opened this issue Jan 1, 2024 · 12 comments
Closed
4 tasks done
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open

Comments

@janvanveldhuizen
Copy link
Contributor

Context

No response

Bug description

As soon as instant loading is added to a project, the navigation loses its way and ends up in 404 errors. I discovered this while using the language switcher, but I am not sure if it is related to the switcher, or if it is a general issue with the instant loading feature.

Related links

Reproduction

example.zip

Steps to reproduce

  1. run the project (I use ./run.txt)
  2. observe that the website starts, showing the English Home page
  3. click on 'Test' in the menu
  4. the Test page is displayed, but in the background, it is already failing, see the log:
INFO    -  [14:56:55] Serving on http://0.0.0.0:8000/
INFO    -  [14:57:18] Browser connected: http://localhost:8000/en/
WARNING -  [14:57:21] "GET /en/de/sitemap.xml HTTP/1.1" code 404
WARNING -  [14:57:21] "GET /en/test/sitemap.xml HTTP/1.1" code 404
  1. switch to German using the language switcher, resulting in a 404 error.

When instant loading is removed from the mkdocs.yml files, then everything works properly.

Browser

No response

Before submitting

@squidfunk squidfunk added the needs investigation Issue must be investigated by the maintainers label Jan 5, 2024
@squidfunk squidfunk added bug Issue reports a bug and removed needs investigation Issue must be investigated by the maintainers labels Jan 17, 2024
@squidfunk
Copy link
Owner

Thanks for reporting. The problems stems from the fact that the relative alternate URLs are not correctly resolved after navigating down the tree, as they are not canonicalized. We'll fix that as part of the next instant loading rewrite.

@squidfunk
Copy link
Owner

I've fixed this on a branch in Insiders. This branch will host the next iteration of instant loading that will fix all open bugs and add new capabilities. Please understand that this will take some time to get right, because instant loading is very complex because of the many possible combinations of cases there are.

Once we got everything in its right place, we'll backport fixes (excluding new features) to the community edition.

@squidfunk squidfunk added the resolved Issue is resolved, yet unreleased if open label Jan 17, 2024
@squidfunk
Copy link
Owner

Fixes are now in #6662. Please check if the errors are now fixed when using this version in your project:

pip install git+https://github.com/squidfunk/mkdocs-material.git@fix/instant-loading-bugs

@squidfunk
Copy link
Owner

Released as part of 9.5.5.

@janvanveldhuizen
Copy link
Contributor Author

Thanks. Sorry for not testing the fix earlier. I've been quite busy with work and some private affairs, leaving me with little time for my hobby projects.

@squidfunk
Copy link
Owner

No worries, I hope everything is working now! ☺️

@janvanveldhuizen
Copy link
Contributor Author

janvanveldhuizen commented Jan 28, 2024

Just ran above scenario again:

INFO    -  [20:23:56] Serving on http://0.0.0.0:8000/
INFO    -  [20:24:47] Browser connected: http://localhost:8000/en/
WARNING -  [20:25:35] "GET /de HTTP/1.1" code 302
INFO    -  [20:25:35] Browser connected: http://localhost:8000/de/

Is something wrong on my system?

By the way, even when I remove navigation.instant same thing happens when I click around.

INFO    -  [project://.de] Cleaning site directory
INFO    -  [project://.de] Building documentation to directory: /docs/languages/de/site
INFO    -  [project://.de] Documentation built in 0.19 seconds
INFO    -  Documentation built in 0.90 seconds
INFO    -  [20:34:05] Reloading browsers
INFO    -  [20:34:05] Browser connected: http://localhost:8000/de/
INFO    -  [20:34:05] Browser connected: http://localhost:8000/de/
INFO    -  [20:34:11] Browser connected: http://localhost:8000/en/
INFO    -  [20:34:15] Browser connected: http://localhost:8000/en/test/
WARNING -  [20:34:18] "GET /de HTTP/1.1" code 302
INFO    -  [20:34:18] Browser connected: http://localhost:8000/de/
INFO    -  [20:35:21] Browser connected: http://localhost:8000/de/blog/
WARNING -  [20:35:24] "GET /en HTTP/1.1" code 302
INFO    -  [20:35:24] Browser connected: http://localhost:8000/en/
WARNING -  [20:35:28] "GET /de HTTP/1.1" code 302
INFO    -  [20:35:29] Browser connected: http://localhost:8000/de/
INFO    -  [20:35:36] Browser connected: http://localhost:8000/de/blog/
WARNING -  [20:35:39] "GET /en HTTP/1.1" code 302
INFO    -  [20:35:39] Browser connected: http://localhost:8000/en/

@squidfunk
Copy link
Owner

I'm not able to reproduce. Does it happen with the same reproduction you've posted in the OP?

@janvanveldhuizen
Copy link
Contributor Author

Yes, same example.zip.

To make sure I have a clean environment I deleted all containers and the mkdocs-material docker image.
Then in the mkdocs-material-insiders repo:

git checkout master
git pull
docker build -t mkdocs-material .

Next, in the example directory:

docker run -p 8000:8000 -v ./:/docs mkdocs-material

The web site starts with the English home page.

  • Go to Test: correctly shows the English Test page
  • Switch to Deutsch: opens the German home page, instead of the German Test page
  • Go to Test: shows the German Test page
  • Switch to English: opens the English home page

This is the entire log for these actions:

WARNING -  Config value 'dev_addr': The use of the IP address '0.0.0.0' suggests a production environment or the use of a proxy to connect to the MkDocs server. However, the MkDocs' server is intended for local development purposes only. Please use a third party production-ready server instead.
INFO    -  Building documentation...
INFO    -  [project://.en] Cleaning site directory
INFO    -  [project://.en] Building documentation to directory: /docs/languages/en/site
INFO    -  [project://.de] Cleaning site directory
INFO    -  [project://.de] Building documentation to directory: /docs/languages/de/site
INFO    -  [project://.en] Documentation built in 0.18 seconds
INFO    -  [project://.de] Documentation built in 0.19 seconds
INFO    -  Cleaning site directory
INFO    -  Documentation built in 0.90 seconds
INFO    -  [07:02:25] Watching paths for changes: 'docs', 'mkdocs.yml', 'languages/en/docs', 'languages/en/mkdocs.yml', 'languages/de/mkdocs.yml', 'languages/de/docs'
INFO    -  [07:02:25] Serving on http://0.0.0.0:8000/
INFO    -  [07:03:19] Browser connected: http://localhost:8000/en/
INFO    -  [07:03:23] Browser connected: http://localhost:8000/en/test/
WARNING -  [07:03:38] "GET /de HTTP/1.1" code 302
INFO    -  [07:03:38] Browser connected: http://localhost:8000/de/
INFO    -  [07:04:37] Browser connected: http://localhost:8000/de/test/
WARNING -  [07:04:41] "GET /en HTTP/1.1" code 302
INFO    -  [07:04:41] Browser connected: http://localhost:8000/en/

I also checked what happens after a build.

docker run -p 8000:8000 -v ./:/docs mkdocs-material build
cd site
python3 -m http.server 8080 --bind 127.0.0.1

Open the website and perform the same actions:

Serving HTTP on 127.0.0.1 port 8080 (http://127.0.0.1:8080/) ...
127.0.0.1 - - [29/Jan/2024 08:13:09] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [29/Jan/2024 08:13:09] "GET /en/ HTTP/1.1" 200 -
127.0.0.1 - - [29/Jan/2024 08:13:09] "GET /assets/stylesheets/main.1484e98b.min.css HTTP/1.1" 200 -
127.0.0.1 - - [29/Jan/2024 08:13:09] "GET /assets/javascripts/bundle.1e80c64b.min.js HTTP/1.1" 200 -
127.0.0.1 - - [29/Jan/2024 08:13:09] "GET /en/search/search_index.json HTTP/1.1" 200 -
127.0.0.1 - - [29/Jan/2024 08:13:09] "GET /en/sitemap.xml HTTP/1.1" 200 -
127.0.0.1 - - [29/Jan/2024 08:13:09] "GET /de/sitemap.xml HTTP/1.1" 200 -
127.0.0.1 - - [29/Jan/2024 08:13:09] "GET /assets/javascripts/workers/search.1e90e0fb.min.js HTTP/1.1" 200 -
127.0.0.1 - - [29/Jan/2024 08:13:09] "GET /assets/images/favicon.png HTTP/1.1" 200 -
127.0.0.1 - - [29/Jan/2024 08:13:17] "GET /en/test/ HTTP/1.1" 200 -
127.0.0.1 - - [29/Jan/2024 08:13:22] "GET /de HTTP/1.1" 301 -
127.0.0.1 - - [29/Jan/2024 08:13:22] "GET /de/ HTTP/1.1" 200 -
127.0.0.1 - - [29/Jan/2024 08:13:22] "GET /de/search/search_index.json HTTP/1.1" 200 -
127.0.0.1 - - [29/Jan/2024 08:13:22] "GET /assets/javascripts/lunr/min/lunr.stemmer.support.min.js HTTP/1.1" 200 -
127.0.0.1 - - [29/Jan/2024 08:13:22] "GET /assets/javascripts/lunr/min/lunr.de.min.js HTTP/1.1" 200 -
127.0.0.1 - - [29/Jan/2024 08:13:34] "GET /de/test/ HTTP/1.1" 200 -
127.0.0.1 - - [29/Jan/2024 08:13:38] "GET /en HTTP/1.1" 301 -
127.0.0.1 - - [29/Jan/2024 08:13:38] "GET /en/ HTTP/1.1" 304 -
127.0.0.1 - - [29/Jan/2024 08:13:38] "GET /assets/stylesheets/main.1484e98b.min.css HTTP/1.1" 304 -
127.0.0.1 - - [29/Jan/2024 08:13:38] "GET /assets/javascripts/bundle.1e80c64b.min.js HTTP/1.1" 304 -
127.0.0.1 - - [29/Jan/2024 08:13:38] "GET /en/search/search_index.json HTTP/1.1" 304 -
127.0.0.1 - - [29/Jan/2024 08:13:38] "GET /assets/javascripts/workers/search.1e90e0fb.min.js HTTP/1.1" 304 -
127.0.0.1 - - [29/Jan/2024 08:13:38] "GET /en/sitemap.xml HTTP/1.1" 304 -
127.0.0.1 - - [29/Jan/2024 08:13:38] "GET /de/sitemap.xml HTTP/1.1" 304 -

Is there anything on my system that I can check to give you more insight in what's happening?

@squidfunk
Copy link
Owner

Hmm, that is so odd. It worked before, but I can clearly see the problem. I'm sorry for the inconvenience this is causing you. I'll look into it asap.

@squidfunk
Copy link
Owner

squidfunk commented Jan 30, 2024

I know where this is coming from. For the instant navigation refactoring, we needed to change the sitemap resolution, which now resolves all URLs to absolute destinations. This was identified to be necessary to not get problems on slow connections. My testing shows that 871fc83 fixes the issue. We'll refactor it when we work on multi-language support again.

@janvanveldhuizen
Copy link
Contributor Author

Glad you found it. No hurry. I don't have a mission-critical website. It's just a personal website for hobby and blogging.

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

2 participants