Skip to content

Visiting homepage doesn't set homepage link in sidebar to active #1131

Closed

Description

@groenroos

Bug Report

Steps to reproduce

  1. Include a link to the homepage (README.md or whatever's defined in the homepage setting) in the sidebar
  2. Visit the docs root.

What is current behaviour

  1. The sidebar link to the homepage does not have the active class to highlight it, and its submenu is not expanded.
  2. If the homepage link is clicked, #/README is appended to the URL, and then the active class is included.
    • The URL fragment is always README, even if the file is called something else.

What is the expected behaviour

  1. The sidebar link to the homepage should have the active class, and the submenu should be expanded.
  2. There should only be one canonical URL for the homepage (preferably one without a fragment in the URL)
    • The fragment should at least match the filename defined in homepage

Other relevant information

  • Bug does still occur when all/other plugins are disabled?

  • Your OS: macOS 10.15.4

  • Node.js version: 13.13.0

  • yarn version: 1.22.4

  • Browser version: Chrome 80.0.3987.149

  • Docsify version: 4.11.3

  • Docsify plugins: pagination, copy-code

Please create a reproducible sandbox

Edit angry-hodgkin-3vxu8

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

N/A

Activity

  1. anikethsaha commented on Apr 22, 2020

    @anikethsaha
    Member

    try setting _sidebar.md to

    - Sidebar
    
      - [Home](/)
      - [Another page](another.md)

    / is not same as home.md so I would suggest using / as it will automatically render your homepage and it will set the active links

    PS: thanks for filling the template completely and creating the sandbox.
    its very rare to see here.

  2. groenroos commented on Apr 22, 2020

    @groenroos
    Author

    That does seem to fix the problem, thanks! 🎉

    I do think the weirdness around linking to the proper name of the homepage file is something that should be fixed though. Or at least if this is intended behaviour, maybe it could be documented more clearly?

  3. anikethsaha commented on Apr 22, 2020

    @anikethsaha
    Member

    this is an intended behavior as we do ajax request to the file based on the URL and we do supported remote file rendering and even remote homepage.
    yes, I do think it should be documented.
    Feel free to submit a PR for the docs change

  4. added a commit that references this issue on May 12, 2020
  5. zhouzi commented on May 12, 2020

    @zhouzi

    this is an intended behavior as we do ajax request to the file based on the URL and we do supported remote file rendering and even remote homepage.

    Wouldn't it be possible to check for config.homepage if the file cannot be requested based on the URL? I mean, if the URL is /, obviously.

    I opened a PR to update the documentation btw 🙂

  6. added a commit that references this issue on May 15, 2020
    aad80f9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsrelated to the documentation of docsify itselfpr welcomequestion

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions