docsifyjs / docsify

πŸƒ A magical documentation site generator.
https://docsify.js.org
MIT License
27.57k stars 5.67k forks source link

Sidebar not being displayed and search not working when deployed to GitHub Pages #1623

Closed reymon359 closed 3 years ago

reymon359 commented 3 years ago

Bug Report

The sidebar dissapears and the search stops working when deploying to GitHub Pages

I already submitted an issue in the plugin repo https://github.com/iPeng6/docsify-sidebar-collapse/issues/29, however I decided to submit it here too in case someone can help πŸ˜„

Steps to reproduce

What is current behaviour

The sidebar is not being displayed when deployed to Github Pages

129520874-3405f26f-0c64-4f02-84b5-8faa0562f3d1

However it works locally

129521254-01705fc6-c261-4456-add8-af125dc9964b

What is the expected behaviour

The sidebar should appear when deployed to GitHub Pages the same way it works locally

Other relevant information

Please create a reproducible sandbox

Edit 307qqv236

Mention the docsify version in which this bug was not present (if any)

sy-records commented 3 years ago

You need to set the basePath

basePath: '/collman-fruits-example/',
reymon359 commented 3 years ago

Hi there @sy-records!

Thank you for the suggestion. I tried adding the basePath: '/docsify-sidebar-collapse/', to the window.$docsify object in the repo https://github.com/reymon359/collman-fruits-example index.html file, but it didn't work. πŸ€”

I had a proper look at the docs and tried these too(without success):

In the end this one worked. However, I feel it is a bit unnecessary to add the full raw URL path.

Thank you again for the help and have a great day full of meat πŸ– ! πŸ˜„

SumithChandran commented 2 years ago

This method is ok if the git repo is publicly accessible. If its in an organization and is private it wont work. That's what happened to me.

I too faced the same issue of blank sidebar. After a quick inspect of webpage in chrome I found that when page is hosted, _sidebar.md was facing a fall back issue since it was loaded from each level directory.

The fix that worked for me was to use Nested Sidebar. I just added alias with the intex.html and my issue got fixed.

<script> window.$docsify = { loadSidebar: true, alias: { '/.*/_sidebar.md': '/_sidebar.md' } } </script>

Please try and see if this works

jellehak commented 1 year ago

Just found out that gh-pages is not serving the _sidebar.md files. It seems that it is ignoring files that start with an _ ( caused by Jekyll ). Solution is to add a .nojekyll file at the root.

More on this https://medium.com/@juliakmdev/learning-that-github-pages-struggles-with-certain-file-names-4d867d499ca9

dmgrok commented 9 months ago

@jellehak thanks for sharing, yes that solves the issue πŸ‘

ThomasThelen commented 6 months ago

Can calso onfirm that adding .nojekyllto the project root solves this problem