mmistakes / minimal-mistakes

:triangular_ruler: Jekyll theme for building a personal site, blog, project documentation, or portfolio.
https://mmistakes.github.io/minimal-mistakes/
MIT License
12.24k stars 25.35k forks source link

add sidebar nav instructions to documentation #476

Closed bquast closed 8 years ago

bquast commented 8 years ago

Environment informations


Expected behavior

mmistakes commented 8 years ago

Currently undocumented because I built it as a "one off" for the theme's documentation section. Wasn't really meant to be something as part of the theme as it's not the most straight forward thing to do.

It involves manually listing out all of the links in a _data file and then referencing that set of navigation links with sidebar.nav.Name in the YAML Front Matter of whatever post/page/collection you want it to appear on.

For example, the menu for the theme's documentation was built by:

_data/navigation.yml

# documentation links
docs:
  - title: Getting Started
    children:
      - title: "Quick-Start Guide"
        url: /docs/quick-start-guide/
      - title: "Structure"
        url: /docs/structure/
      - title: "Installation"
        url: /docs/installation/
      - title: "Upgrading"
        url: /docs/upgrading/

  - title: Customization
    children:
      - title: "Configuration"
        url: /docs/configuration/
      - title: "Navigation"
        url: /docs/navigation/
      - title: "UI Text"
        url: /docs/ui-text/
      - title: "Authors"
        url: /docs/authors/
      - title: "Layouts"
        url: /docs/layouts/

  - title: Content
    children:
      - title: "Working with Posts"
        url: /docs/posts/
      - title: "Working with Pages"
        url: /docs/pages/
      - title: "Working with Collections"
        url: /docs/collections/
      - title: "Helpers"
        url: /docs/helpers/
      - title: "Utility Classes"
        url: /docs/utility-classes/

  - title: Extras
    children:
      - title: "Stylesheets"
        url: /docs/stylesheets/
      - title: "JavaScript"
        url: /docs/javascript/

  - title: Meta
    children:
      - title: "History"
        url: /docs/history/
      - title: "Contributing"
        url: /docs/contributing/
      - title: "Old 2.2 Docs"
        url: /docs/docs-2-2/
      - title: "License"
        url: /docs/license/
      - title: "Terms & Privacy Policy"
        url: /terms/

And then in each _doc collection page the following was added to the YAML Front Matter to pull in the navigation in the sidebar.

sidebar:
  nav: "docs"

The better solution for adding the same YAML to multiple pages is with Front Matter Defaults in _config.yml like so:

defaults:
  # _docs
  - scope:
      path: ""
      type: docs
    values:
      sidebar:
        nav: "docs"
bquast commented 8 years ago

Thanks a lot. I had figured out the part about _config.yml but for some reason I didn't think to look at navigation.yml, which of course is a logical place.

I am making a minisite to accompany my recurrent neural network package which means adding a lot of documentation so this is perfect.

http://qua.st/rnn/docs/quick-start-guide/

mmistakes commented 8 years ago

Documentation has been added https://mmistakes.github.io/minimal-mistakes/docs/layouts/#custom-sidebar-navigation-menu

bquast commented 8 years ago

very cool, thanks a lot!

bquast commented 8 years ago

I just went through the documentation, I believe the step about making a collection is missing.

mmistakes commented 8 years ago

@bquast Didn't include that as collection creation is a basic of using Jekyll that can be learned about from the official docs.

bquast commented 8 years ago

Ok I agree. I guess I meant to say that people might not realise that the files need to a collection for the sidebar nav to work, maybe in a note or something. Or perhaps this is obvious to people who use jekyll more frequently than I do.

mmistakes commented 8 years ago

Sidebar nav should work with posts and pages, not just collections.