-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add nav_enabled
variables for more customizable and feature-complete minimal layouts
#1441
Conversation
Alternatively, this could be implemented as a top-level So perhaps a top-level toggle for |
I was able to mock-test this on a live site. I think the approach of adding a site-level toggle will be better |
Here is a sample commit that I assembled for testing purposes on a template site. If this sounds good, I can adjust this pull request accordingly and push it to my fork so that you can see. |
Presumably the default would be to include the sidebar, so to exclude it you would specify
You might support enabling and disabling the sidebar with a front-matter variable as well as a site configuration variable, with the former overriding the latter: ---
title: ...
layout: default
nav_enabled: true
---
# ... Alternatively, the ---
layout: default
nav_enabled: false
---
{{ content }} Then users would specify a ---
title: ...
layout: minimal
---
# ... |
Thanks for the suggestion @pdmosses! I've implemented your idea to handle Here are two more screenshots: first showing the effect of setting Note that this approach is now more backwards-compatible as it keeps the Note that disabling We will also need to update the documentation later. |
Thanks for the updates to the code! Based on a quick look, this seems almost ready for review. To facilitate reviewing, please:
Wouldn't it work if you change |
Yes, that sounds good. We should be able to keep the JavaScript function definitions for navigation so long as they aren't called if the element is not found: this does make a slightly heavier than necessary JavaScript payload for sites that never use the side navigation, but it will perhaps make the configuration more predictable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So sorry for the delay @kevinlin1 - finally feel like I'm catching up to the start of spring quarter. Left one documentation note and one correctness question, but otherwise this seems pretty solid to me.
I'm not too worried about backwards compatibility with minimal
! However, this change does have downstream impacts on users who have heavily modified the sidebar CSS logic. I'll make a brief note in the migration guide for this feature that those users should be careful when upgrading.
## Selectively hiding or showing the sidebar | ||
|
||
[Jekyll's front matter defaults] can be used to apply the `minimal` layout for many pages. But there are also other variables that can control the page layout. In `_config.yml`, you can set `nav_enabled: false` to disable the sidebar navigation panel across the entire site. This can then be selectively enabled on a page-by-page basis by assigning the `nav_enabled: true` page [front matter] variable. For instance, this could be used to enable sidebar navigation on a home page while all other pages have sidebar navigation disabled. | ||
|
||
```yaml | ||
--- | ||
layout: default | ||
title: Home | ||
nav_enabled: true | ||
--- | ||
|
||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is well-written! After some thought, I'm not sure if this should be in the layout docs - rather, this feels like something that should be in configuration (since this is includes a config.yml
variable) and in customization (where we already discuss the minimal
layout - and also update that example). @pdmosses, what are your thoughts? I think you've always had a great eye for the organization of our documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the change to _config.yml
proposed by the PR should be accompanied by adding a corresponding section in docs/configuration.md
. 1
However, I'd prefer to keep the proposed explanation in docs/layout/layout.md
.
The (simplified) examples of layouts in docs/customization.md
indeed need to be updated to be consistent with the (current and proposed) code.
Footnotes
-
I also think the configuration docs page is long overdue for splitting into child pages, but that obviously shouldn't be in this PR. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pushed some changes to the documentation pages: docs/customization.md
and docs/configuration.md
as I saw fit. Feel free to suggest further changes or push commits directly on top of my branch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick turnaround @kevinlin1! This looks solid to me.
I quickly gave this PR branch a spin on some of our other client sites and they work out-of-the-box. When I draft the migration guide for the next release, I'll make a note that
- we've updated the
minimal
layout: users who have overriden just that layout should take a look, but users who inherit from it may see different behaviour - we've updated the sidebar styling, so those with custom sidebars may see different behaviour
@pdmosses, any thoughts?
I may be a bit ambitious and try to also merge in #1440, which gives us a pretty solidly-scoped minor release.
It would be helpful to indicate in what ways the behaviour might differ.
#1440 includes a major update to the docs for the main navigation in connection with #1431, so #1440 needs to be merged in the same release as #1431 (which hasn't yet been reviewed). In fact some of the new docs pages in #1440 are more than 3 levels deep, and they won't appear correctly in the navigation until the theme supports multi-level. Although the present PR and #1431 both affect the default layout, I don't see a significant advantage of merging them in the same release, as they address completely different issues. |
Ah! Apologies - I had meant to tag #1431, not #1440. 100% my fault - sorry for the confusion. Definitely agree with all the analysis here!
Certainly not required. I can go ahead and release this soon then! Will merge this in now. Re:
I will be sure to do that in the migration guide. Thanks for all your work in drafting + implementing this feature @kevinlin1! |
nav_enabled
variables for more customizable and feature-complete minimal layouts
For a while now, we have implemented and maintained a
minimal
layout #959 that removes the sidebar, search, and auxiliary navigation links (buttons next to the search bar). It turns out that there's actually a relatively simple way to enable search and aux links features. Here's what I did:minimal.html
with the latest copy ofdefault.html
.{% include components/sidebar.html %}
, to avoid rendering the sidebar in theminimal.html
layout.mx-auto
utility class to themain
div
to horizontally-center themain
div
.The result is depicted in the following mockup. (Due to a dependency chain issues, I wasn't able to fully test the site on my local machine.)
Here is the old (current) version of the minimal layout for reference.
Benefits
This change should allow the configuration options like
search_enabled
andaux_links
to work on minimal layouts.I think this approach also brings improved maintainability: although we'll still need to contend with managing two different layout files, at least the diff between the two layout files is now much smaller.
Can you test this change and let me know what you think? Thanks in advance!