# Custom menu markup for Advanced Menu in Coded Template

**URL:** <https://community.hubspot.com/t/custom-menu-markup-for-advanced-menu-in-coded-template/15709>\
**Category:** CMS Development\
**Tags:** navigation\
**Created:** [August 12, 2019, 11:06am UTC](https://community.hubspot.com/t/custom-menu-markup-for-advanced-menu-in-coded-template/15709 "2019-08-12T11:06:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![TomekR](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/tomekr/32/93181_2.png) [@TomekR](https://community.hubspot.com/u/TomekR)\
**Post date:** [August 12, 2019, 11:06am UTC](https://community.hubspot.com/t/custom-menu-markup-for-advanced-menu-in-coded-template/15709/1 "2019-08-12T11:06:15Z")

</div>

Hello,

I am trying to implement own (very simplified, semantic and minimum wrappers) html markup for menus in HubL. Default markup from menu module has several problems (including absence of nav tag and crazy amount of useless attributes and classes).

**Attempt #1: Get menu data from menu module with export\_to\_template\_context**

Putting a classic Advanced Menu module and exporting it to template context makes like this:

`{% menu "menu_tag" site_map_name="Menu name in settings", overrideable=True, root_type="site_root", flyouts="true", max_levels="2", flow="horizontal", label="Menu name in editor", export_to_template_context=True %}`

does make the page being able to choose the menu for the page and givew me some of the information about the menu in widget\_data.menu\_tag, but I cannot see the menu items themselves. The widget\_data.menu\_tag object only extracts: site\_map\_name, root\_type, max\_levels, parent\_widget\_container, label, flyouts, export\_to\_template\_context, flow and overrideable.  
**Q: Is there any data structure there that I am missing? Is there any way to access Advance Menu items from widget\_data?**

**Attempt #2: Use HubL menu function ([HubL functions - HubSpot docs](https://designers.hubspot.com/en/docs/hubl/hubl-supported-functions#menu))**

With this

```auto
{% set node = menu(987) %}
{% for child in node.children %}
	{{ child.label }}
{% endfor %}

```

I am able to generate a fully custom markup, but I need a **menu\_id** parameter as an integer, so I have to set the menu id in the template code so it’s not possible to change that per page. I tried using **widget\_data.menu\_tag.site\_map\_name** as a parameter after using **Attempt #1** code, but it’s not integer.

**Q: Any idea on how to get integer menu\_id from Advanced Menu widget\_data?**

---

<div class="post-metadata">

**Author:** ![stefen](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/stefen/32/29274_2.png) [@stefen](https://community.hubspot.com/u/stefen)\
**Post date:** [August 12, 2019, 12:54pm UTC](https://community.hubspot.com/t/custom-menu-markup-for-advanced-menu-in-coded-template/15709/2 "2019-08-12T12:54:05Z")

</div>

@TomekR an easy way to get IDs of things in HubSpot is to look at the URL when viewing that thing. This works for pages, HubDB tables, forms, ctas, etc.. So I would assume the menu\_id is the number string at the end of the URL when viewing the menu in the site settings.

---

<div class="post-metadata">

**Author:** ![TomekR](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/tomekr/32/93181_2.png) [@TomekR](https://community.hubspot.com/u/TomekR)\
**Post date:** [August 12, 2019, 1:24pm UTC](https://community.hubspot.com/t/custom-menu-markup-for-advanced-menu-in-coded-template/15709/3 "2019-08-12T13:24:36Z")

</div>

Hey @stefen, I am aware of that. However I would like to achieve this without any manual work from page creators - I would like this to be within template code.

I would love to have a template that gets data from menu chosen in Page Editor and generates markup without having to get the id from the url. I wish to use the template for multiple different pages that might have different menus used. This is especially usefull in multilanguage sites.

---

<div class="post-metadata">

**Author:** ![Kyle-Higgs](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/kyle-higgs/32/94041_2.png) [@Kyle-Higgs](https://community.hubspot.com/u/Kyle-Higgs)\
**Post date:** [August 15, 2019, 5:38pm UTC](https://community.hubspot.com/t/custom-menu-markup-for-advanced-menu-in-coded-template/15709/4 "2019-08-15T17:38:01Z")

</div>

Hey,

I don’t know if this is exactly what you’re looking for, does this help?

If you print menu\_id it returns an interger for the selected menu.

 ![Screenshot 2019-08-15 at 18.34.58.jpg](https://d2qpr2jzcazej7.cloudfront.net/original/3X/3/9/3947f55a12675367af000d1ede8421292407d5c5.jpeg)

---

<div class="post-metadata">

**Author:** ![TomekR](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/tomekr/32/93181_2.png) [@TomekR](https://community.hubspot.com/u/TomekR)\
**Post date:** [August 19, 2019, 8:54am UTC](https://community.hubspot.com/t/custom-menu-markup-for-advanced-menu-in-coded-template/15709/5 "2019-08-19T08:54:26Z")

</div>

OMG! Thank you @Kyle-Higgs - this works perfect. I did not know that there is a Menu data field available in modules. This gives me exactly what I need!

Initially I thought that this is a regular integer field in a custom module, so the Page Editors had to put the id themselves, but this Menu field gives a list of available menus and outputs the integer! Perfect! 🙂 Thank you!

---

<div class="post-metadata">

**Author:** ![Kyle-Higgs](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/kyle-higgs/32/94041_2.png) [@Kyle-Higgs](https://community.hubspot.com/u/Kyle-Higgs)\
**Post date:** [August 19, 2019, 10:32am UTC](https://community.hubspot.com/t/custom-menu-markup-for-advanced-menu-in-coded-template/15709/6 "2019-08-19T10:32:36Z")

</div>

You’re welcome!

I literally discovered the menu field about a week ago, I swear it wasn’t there a few months ago.

Glad I could I help anyway.
