HubSpot has a few built-in tools to make the creation and management of these menus easy, and on the code side multiple solutions for displaying menus so you can pick the solution that makes the most sense for your website.
menu
and simple_menu
fields in tandem with the menu()
function so that there’s a balance between custom solution and intuitive editing experience.
menu
and simple_menu
HubL tags to add menu functionality to custom modules. Adding the tag to a module will render the menu on the page. To enable content creators to configure the menu’s options in the page editor, you’ll need to include the menu or simple menu field in the module as well.
Below, learn more about each type of menu tag.
menu
and simple_menu
) to generate standard menu HTML. Like other HubSpot modules, menu modules are wrapped in module wrapper markup. These div
and span
tags make the module editable with the content editor. The menu markup of both the menu and simple menu modules is the same, with the exception of some of the classes applied to the wrapper and menu containers.
ul
wrapped in a div
with the hs-menu-wrapper
class. This wrapper will have additional classes based on how the module is configured in the page editor, such as enabling flyouts. Learn more about classes added by these settings below.
Within the ul
, each menu item is an a
tag wrapped in a li
. The li
tag has a class that indicates the depth of the item in the menu tree (e.g., hs-menu-depth-1
). When a menu item contains a nested child item, the corresponding li
will have the additional class of hs-item-has-children
. The child menu renders as a nested ul
with the class hs-menu-children-wrapper
.
When you visit a page that is included in your menu tree, the class active-branch
is added to the parent li
items and a class of active
is added to that page’s particular li
item.
li
in the page markup. But the orientation and flyouts options will impact the CSS selectors added to the menu wrapper div
. You can then target these selectors in your CSS.
div
depending on these field settings.
Class | Description |
---|---|
hs-menu-flow-horizontal | Added to the wrapper div when the menu is set to horizontal orientation. |
hs-menu-flow-vertical | Added to the wrapper div when the menu is set to vertical orientation. |
flyouts | Added to the wrapper div when Enable flyouts is selected. |
no-flyouts | Added to the wrapper div when Enable flyouts is not selected. |