Multiple sites sharing the same navigation data

OK, so the content exists on Site A, and you want the footer menus of both Site A and Site B to point to the content on Site A.

Try this:

git clone --single-branch -b hugo-forum-topic-52483 https://github.com/jmooring/hugo-testing hugo-forum-topic-52483
cd hugo-forum-topic-52483
hugo server

Note that the rendered menu entries use relative URLs to point to local content.

Now stop the server and do this:

mv content/capabilities content/xx
hugo server

Note that the rendered menu entries now use absolute URLs pointing to content on the site specified by parentSiteBaseURL in the module’s params configuration file.

This is the footer module:
https://github.com/jmooring/hugo-module-footer

Add the footer module to both sites with this in their respective site configuration files:

[[module.imports]]
path = 'github.com/jmooring/hugo-module-footer'

Using the pageRef menu property in the menu configuration enables the .HasMenuCurrent and .IsMenuCurrent methods to work as intended, which is good for both usability and accessibility.

2 Likes