Enable sticky navigation tabs for index page only #7157
-
|
As the title suggests, I've been looking for a way to have the I tried the following Jinja2 syntax in a template: {% block header %}
{% with features = ['navigation.tabs', 'navigation.tabs.sticky'] %}
{% include "partials/header.html" %}
{% endwith %}
{% endblock %}Which worked on the Jinja2 side of things, however I think there is JS code running which still recognises the feature as being turned off, as the navigation bar gets hidden again on page load. I also tried the more hacky solution of appending to {% block header %}
{{ features.append('navigation.tabs.sticky') or '' }}
{% include "partials/header.html" %}
{% endblock %}Is there any straightfoward way to accomplish this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Hello @ThatOtherAndrew, The If you want to stick to the custom template approach for the index page alone then here are some pointers: Your first approach with the You also need to modify the mkdocs-material/src/templates/base.html Lines 388 to 431 in 1c7e954
|
Beta Was this translation helpful? Give feedback.
Thank you for your quick response. I've had a shot at modifying the config with the following:
The "skeleton" of the sticky navigation tabs load in, however some client JavaScript is immediately hiding it on page load, leaving just the coloured background element.
Doing a bit of rather hacky debugging by throwing
{{ app }}directly into the originalbase.htmlfile, it showed thatnavigation.tabs.stickywasn't being added correctly. Trying again usingset featuresdidn't work either, and my rudimentary Jinja2 knowledge isn't good enough to figure out the most el…