Skip to content

Commit

Permalink
Version pagelinks (#1054)
Browse files Browse the repository at this point in the history
* Allow versioned docs to point to the same page in the different versions

If the version_menu_pagelinks config option is true, then link in the drop-down menu
of the versioned docs points to the current page in the other version, instead of the main page.

This can be useful if the document doesn't change much between the different versions.

Note that if the current page doesn't exist in the other version, the link will be broken.

* Adds version_menu_pagelinks to the userguide

* Typo fix

Co-authored-by: LisaFC <lcarey@google.com>
  • Loading branch information
fekete-robert and LisaFC committed Jun 30, 2022
1 parent 73440c9 commit 8c018e3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion layouts/partials/navbar-version-selector.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
{{ .Site.Params.version_menu }}
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
{{ $path := "" }}
{{ if .Site.Params.version_menu_pagelinks }}
{{ $path = .Page.RelPermalink }}
{{ end }}
{{ range .Site.Params.versions }}
<a class="dropdown-item" href="{{ .url }}">{{ .version }}</a>
<a class="dropdown-item" href="{{ .url }}{{ $path }}">{{ .version }}</a>
{{ end }}
</div>
5 changes: 5 additions & 0 deletions userguide/content/en/docs/Adding content/versioning.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ version_menu: 'Releases'
{{< /tab >}}
{{< /tabpane >}}

If you set the `version_menu_pagelinks` parameter to `true`, then links in the version drop-down menu
point to the current page in the other version, instead of the main page.
This can be useful if the document doesn't change much between the different versions.
Note that if the current page doesn't exist in the other version, the link will be broken.

You can read more about Docsy menus in the guide to
[navigation and search](/docs/adding-content/navigation/).

Expand Down

0 comments on commit 8c018e3

Please sign in to comment.