jimporter / mike

Manage multiple versions of your MkDocs-powered documentation via Git
BSD 3-Clause "New" or "Revised" License
528 stars 47 forks source link

No Version selector and error in mike serve logs #113

Closed Skier23 closed 1 year ago

Skier23 commented 1 year ago

I followed the mike and mkdocs-material tutorials. My site is up and has the version in the url address and appears to version correctly if I manually change the version in the url. However, there is no version selector and mike is flooding the chat with the following message: 127.0.0.1 - - [01/Sep/2022 09:14:54] code 404, message File not found 127.0.0.1 - - [01/Sep/2022 09:14:54] "GET /livereload/865877890/865878312 HTTP/1.1" 404 -

jimporter commented 1 year ago

Do you have a repository I could look at with your configuration and the generated HTML? It's difficult to diagnose errors like this without seeing the full setup.

Skier23 commented 1 year ago

I wouldn't be able to share my setup due to company internal reasons. Do you have an idea of where to look for or any ideas of what to look for that could cause this?

jimporter commented 1 year ago

You could try using one of the built-in themes (e.g. mkdocs) to see whether this is a configuration issue with the Material theme. You might also want to look at whether the gh-pages directory structure looks right. It should be something like:

/1.0
    index.html
    ...
/2.0
    index.html
    ...
.nojekyll
index.html
versions.json

Finally, you can check the commit logs on the gh-pages branch to make sure that everything looks reasonable. It should provide some information about how the pages were generated (Mkdocs/mike versions plus the source commit SHA).

Skier23 commented 1 year ago

You could try using one of the built-in themes (e.g. mkdocs) to see whether this is a configuration issue with the Material theme. You might also want to look at whether the gh-pages directory structure looks right. It should be something like:

/1.0
    index.html
    ...
/2.0
    index.html
    ...
.nojekyll
index.html
versions.json

Finally, you can check the commit logs on the gh-pages branch to make sure that everything looks reasonable. It should provide some information about how the pages were generated (Mkdocs/mike versions plus the source commit SHA).

I tried simplifying everything down to just having one index file. However, I deleted the gh-pages branch both locally and the remote and I uninstalled and reinstalled mike but yet somehow when I serve with mike it still shows the old site and not the new one with just the index file. How is this possible?

jimporter commented 1 year ago

You probably didn't fully delete the branch. Per the documentation, to keep in sync with upstream changes, mike will "automatically update your local branch to match the remote's if possible (note that mike won't automatically git fetch anything)". I'm guessing you left origin/gh-pages in your local clone.

You shouldn't need to delete it anyway; if you want a fresh state, you can run mike delete --all, which just adds a new commit that removes all the files from the gh-pages branch.

Skier23 commented 1 year ago

Thanks. That got the history deleted correctly. The version spinner shows up now but the error messages are still in the console: 127.0.0.1 - - [02/Sep/2022 11:38:49] code 404, message File not found 127.0.0.1 - - [02/Sep/2022 11:38:49] "GET /livereload/865877890/865878312 HTTP/1.1" 404 -

I've simplified everything to the point that this is my mkdocs.yml:

site_name: Redacted
#theme:
#  name: material
#  palette: 
#    # Palette toggle for light mode
#    - scheme: default
#      toggle:
#        icon: material/brightness-7 
 #       name: Switch to dark mode

    # Palette toggle for dark mode
#    - scheme: slate
#      toggle:
#        icon: material/brightness-4
#        name: Switch to light mode

#  features:
#    - navigation.instant
#    - navigation.tracking
#    - navigation.tabs
#    - navigation.tabs.sticky

repo_url: redacted
repo_name: redacted
nav:
  - Home:
    - Home: index.md
#    - Readme: README.md
#    - Change Log: CHANGELOG.md
#  - Guides:
#    - Intro Guide: Guides/intro.md
#    - Guide Template: Guides/guidetemplate.md
#  - Explanation:
#    - Intro Explanation: Explanation/intro.md
#    - Explanation Template: Explanation/explanationtemplate.md
extra:
  version:
    provider: mike
    default: 1.1
  generator: false

plugins:
  - mike:
      version_selector: true
copyright: redacted

and here is the one refenced index.md:

# Title

Intro information explaining what Redacted is and why it's a big deal.

It looks like it is trying to reference some 1.1 version. I previously had a 1.1 version but I've since done the mike delete --all command multiple times so I'm confused where its still finding this (if that is what is occurring).

jimporter commented 1 year ago

The only 1.1 I see in the log is HTTP/1.1, but that's just the version of the HTTP protocol being used. The logs look like it's doing something weird with livereload. Since mike serve doesn't use livereload, I don't think that's a mike issue.

Do you happen to have an old tab open from looking at local docs generated by mkdocs serve? That would probably issue requests to livereload until you get rid of that tab...

Skier23 commented 1 year ago

The only 1.1 I see in the log is HTTP/1.1, but that's just the version of the HTTP protocol being used. The logs look like it's doing something weird with livereload. Since mike serve doesn't use livereload, I don't think that's a mike issue.

Do you happen to have an old tab open from looking at local docs generated by mkdocs serve? That would probably issue requests to livereload until you get rid of that tab...

Yea that must've been the issue. Thanks for all the quick help! Closing this issue.