How to Insert AMP Widgets in Magento 2

The Magento 2 AMP extension provides you with various templates to display AMP banners, sliders, subcategories, and other widgets. The following guide describes two ways of creating AMP widgets: using the “Content” -> “Widgets” Menu and Adding Widgets to CMS pages/blocks. Both methods allow you to create the following types of AMP widgets:

  • AMP Catalog New Products List
  • AMP Category Product Carousel
  • AMP Newsletter Subscription Form
  • AMP Slider
  • AMP Static Banner
  • AMP Subcategories
  • AMP Video

How to Add AMP Widgets Using “Content” -> “Widgets” Menu

Adding AMP Widget

Step-by-step guide:

  1. In the main Magento menu, go to Content -> Elements -> Widgets.
  2. Above the Widgets grid, click Add Widget.
Magento 2 AMP extension Adding AMP Widgets 1.png

Step-by-step guide:

  1. “Type”: select the type of AMP widget from a drop-down list.
  2. “Design Theme”: choose AMP theme to display widget on. You can select the default AMP Theme One or any custom AMP theme if you have created one.
  3. Click Continue to proceed.
Magento 2 AMP extension Adding AMP Widgets 2.png

Configuring Storefront Properties

Step-by-step guide:

  1. Go to the Store Properties tab.
  2. You have already set the “Type” and “Design Package/Theme” options in the previous step.
  3. “Widget Title”: enter a descriptive title for the widget. This title is visible only from the backend.
  4. “Assign to Store Views”: select the store view(s) where the widget will be visible.
  5. (Optional) “Sort Order”: enter a number that determines the order this item appears with others in the same container.
Magento 2 AMP extension Adding AMP Widgets 3.png

Step-by-step guide:

  1. “Add Layout Update”: press this button to configure the widget placement.
  2. “Display On”: select the pages, categories, or products where you want the widget to appear.
  3. Configure widget layout. Configurations there will differ depending on the selected Display On option.
Magento 2 AMP extension Adding AMP Widgets 4.png

Configuring Widget Options

Depending on the selected widget type, the following Widget Options configurations will differ. In this example, we will show you how to configure the Static Banner widget type.

Step-by-step guide:

  1. Switch to the Widget Options tab.
  2. “Link Url”: optionally provide a URL of a widget if you want it to take users to a specific page.
  3. “Open Link in New Window”: set the option to Yes if you want to open the provided link in a new window.
  4. “Image”: click Choose Image to select the image to be showcased on the widget.
  5. “Alt”: specify an alternative text for the selected image.
  6. Set image dimensions.
  7. Click Save to save the widget.
Magento 2 AMP extension Adding AMP Widgets 5.png

The widget will appear in the Widgets grid. Clear Magento cache to display the widget on the frontend.

How to Add AMP Widget to CMS Pages/Blocks

Unlike the “Content” > “Widgets” Menu, you can display AMP widgets anywhere within the CMS page/block content. Therefore, this method is more flexible if you add widgets to complex CMS pages and CMS blocks with plenty of elements.

In the following steps, you need to add AMP widgets to the AMP Content field of the needed CMS block or page.

Adding AMP Widget

In this example, we will show you how to add AMP widgets to a Homepage. However, you can add AMP widgets to any CMS page or CMS block for AMP following the guide below.

Step-by-step guide:

  1. In the main Magento menu, navigate to Content -> Pages.
  2. In the CMS Pages grid, find the needed page where you want to add a widget. Click Select -> Edit on the corresponding record to edit the CMS page.
Magento 2 AMP extension Adding AMP Widgets 6.png

Step-by-step guide:

  1. Scroll down to the AMP Content section, click where you want to insert a widget and press the Insert Widget button.
Magento 2 AMP extension Adding AMP Widgets 7.png

Configuring Widget Options

Step-by-step guide:

  1. “Widget Type”: select the widget type from the drop-down list.
  2. “Link Url”: optionally provide a URL of a widget if you want it to take users to a specific page.
  3. “Open Link in New Window”: set the option to Yes if you want to open the provided link in a new window.
  4. “Image”: click Choose Image to select the image to be showcased on the widget.
  5. “Alt”: specify an alternative text for the selected image.
  6. Set image dimensions.
  7. Click Insert Widget.
Magento 2 AMP extension Adding AMP Widgets 8.png

Step-by-step guide:

  1. Now you can see that the widget code appeared in the AMP content section.
  2. Click Save to apply all changes made to the Amp Theme Ome Homepage 1.
  3. Click AMP Validation to check if your CMS page is valid after the changes have been made.
Magento 2 AMP extension Adding AMP Widgets 8.png

Checking the Result

Go to your storefront and check the widget display. This is how the created widget looks on the Magento 2 frontend:

Magento 2 AMP extension Adding AMP Widgets 12.png

Was this article helpful?