Skip to content

Keep the docs menu in view and add previous/next topic links - #26

Closed
madolson wants to merge 9 commits into
mainfrom
docs-modern-sidebar
Closed

madolson wants to merge 9 commits into
mainfrom
docs-modern-sidebar

Conversation

@madolson

@madolson madolson commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

On valkey.io the docs menu scrolls away with the page. On a long topic like /topics/replication/ that leaves about 10,700px of empty lavender column, and on phones the menu is rendered after the content, 27,948px down a 30,850px page. Neon's docs keep the menu stuck in view with its own scroll. This PR does the same: on wide screens the menu sticks to the top of the window and scrolls on its own, jumping to the current entry if it starts out of view, and on narrow screens it moves above the content as a closed "Documentation menu" toggle. Three other options are in the details.

A docs topic page ends with no way to keep reading, so a reader working through the docs goes back to the menu after every page. This adds Previous and Next links at the end of each topic, in the order the docs menu lists them, crossing from the end of one section into the start of the next. Command pages don't get them. Topic and command pages also get a "#" link on each heading for linking to a section, and, on command pages, the "Update this Page on GitHub" link that topic pages already have.

Before on the left, after on the right, at 1440x900.

/topics/ top:

/topics/ halfway:

/topics/replication/ halfway:

/topics/replication/ at the end of the article:

/commands/set/ 40% down:

/commands/zunionstore/ on load:

/topics/replication/ at 390px wide: before, after, and after with the toggle opened.

Previous and next links

First topic (introduction), before and after:

before
after

Middle topic (large-object-getting-started), before and after:

before
after

Last topic (history), before and after:

before
after

390px wide, before and after:

before
after

Heading links, Edit on GitHub

/topics/replication/ heading while hovered, before and after, then reached with Tab:

before
after
after, keyboard focus

/commands/set/ end of the docs menu, before and after:

AI generated details

Neon vs valkey.io

Computed styles from headless Chrome at 1440x900, on https://neon.com/docs/introduction/branching and https://valkey.io/topics/replication/.

Neon valkey.io (main)
Header sticky, 60px position: relative, 81px, scrolls away
Sidebar full-height aside, inner wrapper position: sticky; top: 60px static, scrolls with the page
Own scroll height: calc(100vh - 3.75rem); overflow-y: scroll, scrollbar hidden none
Look 312px column, 1px right border, no card lavender column up to 420px, content in a white rounded card
Long page, halfway menu in view menu is 1,178px of an 11,859px column; the rest is empty
End of page footer pushes the sticky panel up menu long gone
Sections groups always expanded, nested items behind chevrons sections are <details>, only the current one open
Current page accent text, weight 500, no aria-current blue background, 4px left border, aria-current="page"
"On this page" right column, sticky at 84px, scroll-spy, 1280px and up none
Under 1024px sidebar hidden; fixed bottom bar opens the menu menu after the content (y=27,948 of 30,850)

Options

  1. Sticky sidebar with its own scroll (this PR). Wide: menu sticks at the top of the window, at most 100vh, scrolls on its own, and scrolls to the current entry on load if it is out of view. Narrow: closed toggle above the content. Keeps the current look.
  2. Sticky header plus sticky sidebar (Neon's full model). Loses: the header is shared by every page, so it costs 81px of every viewport site-wide and edits templates/default.html and .header, which Route /docs/ to the topics index and link Clients and Integrations in the docs menu valkey-io/valkey-io.github.io#742 also edits. Can go on top of 1 later by changing top.
  3. Option 1 plus a right-hand "On this page" list. Loses for now: topics go through the markdown filter in the template, so there's no page.toc. It needs JS that builds the list from headings and a third column, which narrows content from 940px to about 700px at 1440px. Good next stage.
  4. Flat restyle: drop the lavender column and white card for a full-height sidebar with a divider. Loses: a visual redesign rather than a behavior fix, and it collides with the Restyle the homepage below the hero as /community/ cards valkey-io/valkey-io.github.io#747 and Redesign /blog/ as a featured lead post and list, and put posts in /community/ cards valkey-io/valkey-io.github.io#749 restyles of sass/_valkey.scss.

For narrow screens, Neon's fixed bottom bar with a drawer loses to a <details> toggle: it adds a fixed overlay and more JS for the same result.

Why it happens

templates/left-aside.html:13-15 (main) puts the aside after main. sass/_valkey.scss:509 lays them out as a column below 1024px, so the menu lands after the content, and :516 uses row-reverse above it. The aside rule at sass/_valkey.scss:552 has no positioning.

Change

  • templates/left-aside.html:13-39: the aside's content is wrapped in <details class="docs-sidebar" open>. An inline script closes it below 1024px, reopens it when the window widens, and on wide screens scrolls the menu (not the page) when the current entry (.docs-menu-current, else .docs-menu-related) starts below the visible part.
  • sass/_valkey.scss:588-597: .left-aside .docs-aside gets order: -1 below 1024px so the menu sits above main. At 1024px and up it hands its padding to the sticky panel.
  • sass/_valkey.scss:602-657: the summary is a white toggle bar on narrow screens. At 1024px and up: position: sticky; top: 0; max-height: 100vh; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin, summary hidden.
  • Without JS the <details> stays open: desktop is unchanged, narrow screens show the open menu above the content.
  • Only the four templates that extend left-aside.html change (docs, docs-page, commands, command-page). templates/blog-aside.html also uses .left-aside and is unaffected.
  • Precedent: .right-styled aside is already position: sticky; top: 0; height: 100vh (sass/_valkey.scss:806-818 on main).

Decisions

  1. Which option. Proposal: 1 now, 3 as a follow-up.
  2. Keep the narrow-screen toggle here or split it out. Proposal: keep. Without it the menu is unreachable on long pages.
  3. Toggle label. Proposal: "Documentation menu". Alternatives: "Menu", "Docs menu".
  4. On narrow screens the menu is visually first but still after main in the DOM, so keyboard and screen reader users reach it after the content. Desktop already works this way (row-reverse). Proposal: keep. Moving the aside first in the DOM changes tab order on every docs page.

Overlaps

Testing

Only checked in headless Chrome. Safari and Firefox are unverified. Safari before 18.2 ignores scrollbar-width.

Previous and next links (from #27)

Decisions

Order is the menu's. Each section's landing page (the menu's "Overview"), then its topics, section after section. It's computed from the same nav_merged result the menu is rendered from (templates/docs-page.html:20), so module sections (Search, Large object) and module topics (bloomfilters, valkey-json, ldap, valkey-bundle) land where the menu shows them, and the two can't drift apart.

Section boundaries: cross. Stopping would dead-end the last page of 13 of the 14 sections. The breadcrumb already says which section you're in. Docusaurus, MkDocs Material and VitePress all cross without marking it.

Command reference: skipped. It's a list of 457 commands, not a page you read next. After valkey-bundle (end of Getting started) comes data-types. The Clients, Integrations and Valkey Admin menu links from valkey-io#742 come from config, not nav_merged, so they're skipped too.

First and last pages. introduction shows only Next, history only Previous. No wrap-around. Next stays on the right when it's alone.

Command pages: none. 457 pages with no reading order: alphabetical puts APPEND between ACL WHOAMI and ASKING. Someone on a command page is looking it up, not reading through, and the breadcrumb and the menu's command list under the related topic already link the topic and its sibling commands.

Titles are the topic's own front matter title, the same as its H1, not the shorter menu title. Menu titles like "Getting started" and "Configuration" (Large object, Search) only make sense under their section heading.

Topic not in the menu: no links, and its would-be neighbours skip it. Today all 84 topics are in the menu.

Implementation

  • nav_pager component, templates/macros/nav.html:230-271: flattens the menu, finds the page, renders the links. Called once at the end of the content, templates/docs-page.html:63.
  • .docs-pager, sass/_valkey.scss:2413-2464. Inside the content card under a 1px #d5d9ec rule (the menu's section divider). Padding, radius, #d1d9ff hover and #2054B2 focus outline are the menu links'. The label is #444, like the topic index descriptions. No new colors. Stacks below 768px.
  • Links carry rel="prev" and rel="next"; the block is a <nav aria-label="Previous and next topics">.

Testing

A Python script recomputes the order from nav.yml and modules-nav/*.yml independently of the templates, and checks the hrefs on every built page:

84 topics in reading order, 84 topic pages
duplicates in menu: none
topic pages not in the menu (no prev/next): none
checked 84 menu topics, 0 unlisted topics, command pages: 0 errors
first: introduction last: history

With faq removed from a scratch copy of nav.yml: faq has no pager and installation's Next is migration. Also built merged with valkey-io#742: same 84 of 84.

Not verified: hover and focus states visually (static headless screenshots only), and screen reader output.

Overlaps

For you to decide

  • Mark section crossings (e.g. "Next: Cluster")? Proposal: no, the titles already say where you're going.

Heading links, Edit on GitHub

Heading links

Template-side, no JS. Zola's insert_anchor_links only reaches page.content. Topics and command descriptions go through the markdown filter (templates/docs-page.html:62, templates/command-page.html:169), which ignores it: with [markdown] insert_anchor_links = "right" in config.toml, blog posts get anchors and /topics/replication/ and /commands/set/ get none. So heading_links (templates/macros/docs.html:63-71) rewrites the rendered HTML with regex_replace, appending <a class="heading-link" href="#id" aria-label="Link to this section">#</a> inside each <h2 id> and <h3 id>. The links work without JS and nothing shifts on load.

Scope. h2 and h3 in topic bodies and command descriptions, plus the template's "Deprecation advice" and "History" headings (templates/command-page.html:176,209). History had no id and now has id="history"; no command doc has a History heading of its own. h1 and h4 are left alone. All 2,372 content h2/h3 get a link to their own id. Apart from those links, the new id, the command Edit links and whitespace, the built pages are unchanged, and every code block is byte-identical.

Visibility (sass/_valkey.scss:2240-2256). opacity: 0 until the heading is hovered or the link has focus, so the link stays in the tab order, which visibility: hidden would not. Always shown on (hover: none) screens, which can't hover.

Accessible name. "Link to this section". The link sits inside the heading, so a screen reader's headings list reads "How Valkey replication works Link to this section". Zola's own anchors, VitePress and Docusaurus make the same tradeoff. Putting the link after the heading instead, as GitHub does, needs a wrapper around every heading, which breaks the .main-inner > h2 margins (sass/_valkey.scss:531). Proposal: keep.

Copy buttons on code blocks were dropped (c8d7631): blocks mix commands with prompts and replies, so copying a whole block grabs text that can't be run.

Edit on GitHub

Same markup and text as on topic pages. On both, it ends the page content, above the previous and next links (templates/docs-page.html:64-67, templates/command-page.html:230-233), so the closed menu toggle on phones doesn't hide it. It points at https://github.com/valkey-io/valkey-doc/edit/main/commands/<slug>.md.

Module commands link to valkey-doc too. Their descriptions live there, not in the module repos: build/init-commands.sh:83 creates a page only for each valkey-doc/commands/*.md, and valkey and the module repos supply only the JSON metadata (syntax, complexity, history). All 457 pages, bf.*, json.*, ft.* and blob.* included, have a valkey-doc file.

For you to decide

  1. Also link the metadata JSON (valkey/src/commands/<name>.json or the module repo's)? Proposal: no. Readers report errors in the description, and the generated stub already names the JSON's repo.

Overlaps

Testing

Scripted in headless Chrome over CDP against zola serve of this branch, all passing:

  • Tab from the top of /topics/replication/ reaches a heading link, which becomes visible; Enter sets location.hash to the heading's id. Hover shows the link, moving away hides it, click sets the hash.
  • 390px with touch emulation: links shown, no horizontal overflow.
  • Edit links: all 457 command pages' paths exist in valkey-doc's main tree (GitHub API). HEAD on 42 blob/main URLs (17 picked core and module commands, 25 random): all 200, and a made-up doesnotexist.md is 404. The /edit/ URLs themselves answer 302 to login for anonymous requests whether or not the file exists, so they can't be checked directly.

Not verified: Safari and Firefox, screen reader output.

This was generated by AI but verified, with love, by a human.

The docs menu scrolled away with the page, leaving an empty column next
to long topic and command pages. On wide screens it now sticks to the top
of the window, at most a window tall, and scrolls on its own. If the
current page's entry starts out of view, the menu scrolls to it.

On narrow screens the menu came after the page content, so it was at the
bottom of long pages. It now sits above the content as a closed
"Documentation menu" toggle.

Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
@madolson madolson added the needs-review Staged work waiting on madolson's review label Nov 17, 2026
@github-actions

Copy link
Copy Markdown

Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
Each h2 and h3 in the docs content gets a "#" link to itself, shown
while the heading is hovered or the link has focus, and always on touch
screens. Zola's insert_anchor_links doesn't apply to the markdown
filter the templates use, so heading_links adds the links to the
rendered HTML. The History and Deprecation advice headings on command
pages get them too; History gets an id for it.

Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
copy-code.js wraps each code block in the docs content and adds the
same button as the release pages' .copy-code blocks, so the existing
click handler does the copying and announces it. The button sits in
the block's top right corner, in colors for the dark code theme.
Blocks that are already .copy-code are skipped.

Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
Topic pages link to their valkey-doc source below the docs menu.
Command pages now do the same. Every command page, module commands
included, is built from a description in valkey-doc's commands/
directory (build/init-commands.sh), so the link always points there.

Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
@madolson madolson changed the title Keep the docs menu in view while the page scrolls Keep the docs menu in view and add previous/next topic links Nov 17, 2026
Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
Reverts f9ac5e3. Many docs code blocks mix commands with prompts and
replies, so copying a whole block grabs text that can't be pasted and
run.

Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
On narrow screens the menu is a closed toggle, which hid "Update this
Page on GitHub" on topic and command pages. It now ends the content,
above the previous and next links, on every screen size.

nav_pager found the current topic with five set_global variables. It
now finds its index with a comprehension and needs set_global only to
build the reading order.

Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
@madolson madolson added promoted Change has been promoted upstream and removed needs-review Staged work waiting on madolson's review labels Nov 17, 2026
@madolson

Copy link
Copy Markdown
Owner Author

Promoted upstream: valkey-io#773

@madolson madolson closed this Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

promoted Change has been promoted upstream

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant