A starter script for quickly building HubSpot menu's using the menu() function.
Created by: Jon McLaren
Tags: Menus and navigation
After receiving a minimum of 25 recommendations, an entry earns the "Community Approved" badge.
Please keep in mind, all entries are community created and may not be fully supported by HubSpot.
View on:
{%- macro render_link_item(link,depth)-%}
{%- if link != [] && link.label -%}
<li class="hs-menu-item hs-menu-depth-{{depth}} {{'hs-item-has-children' if link.children}}" aria-role="none" {{'aria-haspopup="true"' if link.children}}>
<a href="{{link.url if link.url else '#'}}" aria-role="menuitem">{{link.label}}</a>
{%- if link.children -%}
<ul class="hs-menu-children-wrapper" aria-role="menu">
{% set depth = depth + 1%}
{%- for sublink in link.children -%}
{{render_link_item(sublink,depth)}}
{%- endfor -%}
</ul>
{%- endif -%}
</li>
{%- endif -%}
{%- endmacro -%}
<nav class="sc-site-header__menu sc-site-header__menu--{{ module.menu_field }} hs-menu-wrapper active-branch flyouts hs-menu-flow-horizontal" aria-label="{{menu_name}} menu">
{% set menu = menu(module.menu_field , "site_root").children %}
<ul aria-role="menubar">
{% for link in menu %}
{{render_link_item(link,1)}}
{% endfor %}
</ul>
</nav>
/* This module gets most of it's styles from the HubSpot boilerplate css to start, add your own styles if necessary. */
// No JS needed
This is a basic menu module to use as a starter for your own menus using the HubSpot menu()
function.
Intentionally it does not have any CSS of it's own. When popped into a page using HubSpot's boilerplate css however it will render just like the HubSpot menu tag menu's do.
You can then easily modify the html to fit your specific needs to build mega menus or other advanced features.
A modern framework for accelerating build times on the HubSpot CMS. Based on a modified Bootstrap 4 framework.
Lead developers: Jon McLaren
Chrome/Chromium extension for HubSpot CMS Developers that adds a developer menu, dark theme and useful shortcuts to commonly used HubSpot query parameters, resources, and tools for making HubSpot Development easier and more enjoyable.
Lead developers: Jon McLaren , William Spiro , Gonzalo Torreras
This extension enables super fast local development of CMS pages, and is a great compliment to using the new local HubL server. It contains comprehensive HubL tag, function, filter and expression test auto-complete snippets, as well as their documentation.
Lead developers: William Spiro
Find an entry with an issue, bug, or abuse?
Please complete the below information in detail and we will investigate.
Reporting as Luke Summerfield