Integrating a newsletter signup form in Magento 2 is an excellent way to engage with your customers, keep them informed about the latest products, and drive sales through targeted email marketing. Fortunately, Magento 2 provides several flexible options to insert a newsletter signup form.
This guide will walk you through the process of how to Magento 2 insert newsletter signup form effectively.
First, ensure the newsletter functionality is enabled in your Magento 2 store. To do this:
Magento 2 comes with a built-in newsletter subscription block, which can be added to various positions in your store’s layout. To insert a newsletter signup form in Magento 2, follow these steps:
1. Create or edit the `default.xml` file in your theme at:
app/design/frontend/Vendor/theme_name/Magento_Theme/layout/default.xml
2. Insert the following XML to add the newsletter widget:
```xml
<referenceContainer name="footer">
<container name="newsletter-subscription" as="newsletter" label="Newsletter Subscription" htmlTag="div" htmlClass="footer-sub">
<block class="Magento\Newsletter\Block\Subscribe" name="footer.newsletter" template="Magento_Newsletter::subscribe.phtml"/>
</container>
</referenceContainer>
```
3. Ensure to flush the cache to see the updates:
```bash
php bin/magento cache:clean
php bin/magento cache:flush
```
To match your store's branding, you may want to customize the appearance of the newsletter signup form.
1. You can copy the subscribe template file from the core module to your custom theme for modification. Copy the file from:
vendor/magento/module-newsletter/view/frontend/templates/subscribe.phtml
To:
app/design/frontend/Vendor/theme_name/Magento_Newsletter/templates/subscribe.phtml
2. Customize the HTML and styling as needed.
3. Add or edit CSS rules to style the newsletter signup form. You can do this in your theme’s custom CSS file:
app/design/frontend/Vendor/theme_name/web/css/source/_extend.less
After implementing the newsletter signup form in Magento 2, ensure it's functioning correctly.
Login and Registration Form