jimporter / mike

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

Changes to code not rendering during `mike serve` #32

Closed reginapizza closed 3 years ago

reginapizza commented 3 years ago

Hello! First off, thank you so much for this amazing tool, it's helping me tremendously to add versioning to material theme with mkdocs.

Regarding this issue, I'm almost sure I'm just doing something wrong, but when I run mike serve, my changes are not rendering in the browser when I check my sources in chrome developer tools. I have installed mike and run mike install-extras. When I run mike list I have 1.7 and 1.7.1 [latest], and I've set my default with mike set-default latest. All that works fine, and I can see my dropdown in the sidebar nav. I'm trying to move the dropdown to live in the header, but my code is not picking up the changes. Not sure it's necessary, but I've also run mkdocs build and tried pushing my updated code up to my remote branch, neither of these solved my issue.

My file structure from root looks like:

mkdocs.yaml versions.json docs

js

version-select.js

Not sure what else to try or if I'm doing something wrong, thank you in advance!

jimporter commented 3 years ago

mike serve shows you whatever is currently in your gh-pages branch, not any local changes you've made. To update that, you'll need to run mike deploy to create a commit with the latest changes on your gh-pages branch.

For your case though, the easiest way to edit things would probably be to check out your gh-pages branch and edit version-select.(js|css) directly, then run python -m http.server 8000 to start up a test server to check the results in the browser. Once you're happy with the results, just copy version-select.(js|css) to the docs folder of your main branch.

reginapizza commented 3 years ago

Thanks for the response. I tried what you said and I'm getting:

Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
127.0.0.1 - - [18/Dec/2020 17:47:47] code 404, message File not found
127.0.0.1 - - [18/Dec/2020 17:47:47] "GET /1.7/ HTTP/1.1" 404 -
127.0.0.1 - - [18/Dec/2020 17:47:49] code 404, message File not found
127.0.0.1 - - [18/Dec/2020 17:47:49] "GET /1.7/ HTTP/1.1" 404 -

and my browser just shows a white page with the error response.

These are the steps I took:

Really not sure where exactly I'm going wrong here

jimporter commented 3 years ago

You shouldn't run mike deploy from a checkout of the gh-pages branch, since it won't be able to build your docs (the sources for the docs are on your other branch), and will probably cause weird things to happen. If you have some versioned docs already on the gh-pages branch, then python -m http.server 8000 (from gh-pages) should host your dos locally. For example:

git init
[edit docs]
mike install-extras
mike deploy 1.0 latest
mike set-default latest
git checkout gh-pages
[edit version-select.(js|css)]
python -m http.server 8000
reginapizza commented 3 years ago

Thank you so much @jimporter, this fixed my issue! I guess I just wasn't understanding how this worked with gh-pages but all good now