Skip to content

menu_link

Definition

{% menu_link(options) %}

Input parameters

options

object represents an object of menu link configuration parameters:

Option key Type Default Required Description
options.link object "" yes Object of link configuration parameters
options.classList string "" no A list of css classes that will be added to the link.
Option key Type Default Required Description
options.link.url string "" yes Link to a targetted URL
options.link.title string "" yes Text content of the menu link
options.link.isPopup boolean false no If set to true the link will open in a new tab

Example

In this example we render a regular menu link to privacy policy.

{{ menu_link({
    link: {
        title: 'Privacy policy',
        url: '/link/to/privacy-policy',
    }
}) }}

Example

In this example we render an external menu link that will open in a new tab

{{ menu_link({
    link: {
        title: 'My potfolio',
        url: 'https://example-portfolio.com',
        isPopup: true
    }
}) }}

Example

In this example we render a menu link to a contact form with a custom class

{{ menu_link({
    link: {
        title: 'Contact form',
        url: '/link/to/contact-form',
    },
    classList: 'menu__list-link'
}) }}

Macro source code

{% macro menu_link(options) %}
    <a
        class="js__menu-item js__item-to-aggregate {% if options.classList %}{{ options.classList|join(' ') }}{% endif %}"
        href="{{ options.link.url }}"
        title="{{ options.link.title }}"
        {% if options.link.isPopup %} target="_blank" rel="noopener" {% endif %}
    >
            {{ options.link.title }}
    </a>
{% endmacro %}