How To Add Contact Form To CMS Page In Magento 2

how to add contact form to cms page in magento 2

In this Magento 2 tutorial, we will show you five simple steps to add a contact form to your CMS page (e.g.: Contact us page) in Magento 2. Let’s get started!

Step 1: Add A New CMS Page

Open your Magento 2 admin panel, navigate to CONTENT, select Pages (under Element), then click on Add New Page button.

(Admin Panel > CONTENT > Pages > Add New Page)

add contact form on cms page magento 2

Step 2: Add Information For The CMS Page

Here, you need to enter the Page Title, URL Key, Meta Title, Meta Keyword, Meta Description and select the store view(s) where the page belongs to.

add contact form on cms page magento 2

Step 3: Add Content (HTML) To The CMS Page

It’s up to you to add more information to the Content section.

contact form magento 2

For example, you can insert the Google Maps as the following: firstly, visit the Google Maps, search for your location; secondly, click on Share, select Embed a map and click on COPY HTML; and finally, paste the link to your HTML Content.

magento 2 how to create contact form

Step 4: Add The Contact Form To The CMS Page

You can change the title for each field in the contact form.

In your source code:
app/design/frontend/company/name_theme/ new folder: Magento_Contact
app/design/frontend/company/name_theme/Magento_Contact/ new folder: templates
app/design/frontend/company/name_theme/Magento_Contact/templates/ new file: form.phtml.

In this file, you can customize the form to your need.

Then, to insert the contact form to the CMS page that we are creating, you just need to add: {{block type=’core/template’ name=’contactForm’ template=’contacts/form.phtml’}} to the Content section.

Step 5: Save The Page

Eventually, remember to save the configuration and flush cache (or run the command: php bin/magento cache:flush).

We have given you the detailed instruction to easily add a custom contact form to your CMS Page. If you have any difficulties when following the instruction, be free to leave a comment below. See you in the next tutorial.

Read more:

How To Customize Magento 2 Email Templates in 5 Minutes

How To Create A Credit Memo In Magento 2? (10 minutes)

How To Create A Custom Widget in Magento 2? (5 minutes)

2 thoughts on “How To Add Contact Form To CMS Page In Magento 2

  1. Jeff says:

    I tried going through Step 4 to add a contact form to my CMS page but it doesn’t work. I also tried deploying static content in addition to clearing the cache but still nothing. Any ideas?

    • Mark Mac says:

      Hey Jeff, feel free to email us your question, as it would be quite lengthy to answer your question here. All the best!

Leave a Reply

Your email address will not be published. Required fields are marked *