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

Customize Navigation Sidebar Not Working #1848

Closed Wei2624 closed 5 years ago

Wei2624 commented 5 years ago

Hi, @mmistakes , Thanks for sharing this great Jekyll theme.

I was trying to add Custom Sidebar Navigation Menu as you described in your webpage.

What I have done is to:

1) add directory to navigation.yml like

MachineLearning:
  - title: Supervised Learning
    children:
      - title: "Discriminative Algorithm"
        url: /posts/MachineLearning/sv_discriminative_model/
      - title: "Generative Algorithm"
        url: /_posts/MachineLearning/sv_generative_model/
      - title: "Support Vector Machine"
        url: /_posts/MachineLearning/sv_svm/
      - title: "Bias and Variance Tradeoff"
        url: /_posts/MachineLearning/sv_bias_variance_tradeoff/
      - title: "Learning Theory"
        url: /_posts/MachineLearning/sv_learning_theory/
      - title: "Regularization and Model Selection"
        url: /_posts/MachineLearning/sv_regularization_model_selection/
      - title: "Online Learning and Perceptron"
        url: /_posts/MachineLearning/sv_online_learning_perceptron/
  - title: Deep Learning
    children: 
      - title: "Neural Networks"
        url: /_posts/MachineLearning/dl_neural_network/
      - title: "Backpropagation"
        url: /_posts/MachineLearning/dl_backpropagtion/

2) And then I created a subdoler named _MachineLearning in _posts folder.

3) I added premalink: permalink: /posts/MachineLearning/sv_discriminative_model/ to the first post that is supposed to appear in the sidebar.

However, it returns me a 404 not found error. Do you have any idea of why this happens?

Appreciated in advance!

mmistakes commented 5 years ago

url is the rendered path... e.g. the actual URL of the post after Jekyll builds the site.

You're using the path to the source file which is why those links are coming up as 404. If you look at the demo site and check out the URL of the first post https://mmistakes.github.io/minimal-mistakes/post/post-future-date/ you'd set url like this:

url: /post/post-future-date/

Basically you're using everything except the protocol and domain (and possibly baseurl if you have that set). You could set the entire URL to the absolute path, but that will break things when previewing locally.

url: https://mmistakes.github.io/minimal-mistakes/post/post-future-date/
mmistakes commented 5 years ago

If you need a real world example, here's what I'm using to build the side nav in the documentation section of the theme's site.

https://github.com/mmistakes/minimal-mistakes/blob/master/docs/_data/navigation.yml#L35

Wei2624 commented 5 years ago

It is still not working even if I put the entire url.

image

My navigation.yml file is like:

MachineLearning:
  - title: Supervised Learning
    children:
      - title: "Discriminative Algorithm"
        url: https://wei2624.github.io/posts/MachineLearning/sv_discriminative_model/

My post is saved in this folder on github:

image

The Front Matter is:

---
layout: single
mathjax: true
toc: true
toc_sticky: true
category: Machine Learning
tags: [notes]
qr: machine_learning_notes.png
title: Discriminative Algorithm
permalink: /posts/MachineLearning/sv_discriminative_model/
---

It seems like Jekyll engine does not process this file. Is that the issue?

Thanks for your quick reply! @mmistakes

mmistakes commented 5 years ago

Yes that is your issue. Jekyll isn't building that page.

Jekyll typically ignores folders and files that begin with an underscore. Rename _posts/_MachineLearning to _posts/MachineLearning

Wei2624 commented 5 years ago

@mmistakes Thanks for the reply.

So I made that change but it still does not work.

Do you have any other possible things that I should look at to solve it?

Thanks.

mmistakes commented 5 years ago

It's not working because Jekyll expects _posts to have their filenames in a specific way e.g. YYYY-MM-DD-post-title.md.

If dating these pages doesn't make sense for your site then I'd suggest moving them out of the _posts folder and create a collection. Or if they aren't related make them as stand alone pages.

Closing as this isn't a theme issue. If you need further help use one of these resources, https://jekyllrb.com/docs/community/#where-to-get-support