# Adding add facebook and twitter image meta tags dynamically in landing page

**URL:** <https://forum.mautic.org/t/adding-add-facebook-and-twitter-image-meta-tags-dynamically-in-landing-page/9691>\
**Category:** Product Support\
**Created:** [October 13, 2017, 4:52pm UTC](https://forum.mautic.org/t/adding-add-facebook-and-twitter-image-meta-tags-dynamically-in-landing-page/9691 "2017-10-13T16:52:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lucas](https://avatars.discourse-cdn.com/v4/letter/l/ba8739/32.png) [@Lucas](https://forum.mautic.org/u/Lucas)\
**Post date:** [October 13, 2017, 4:52pm UTC](https://forum.mautic.org/t/adding-add-facebook-and-twitter-image-meta-tags-dynamically-in-landing-page/9691/1 "2017-10-13T16:52:40Z")

</div>

Just sharing one way to add facebook and twitter image meta tags dynamically in landing page:  
  
  
  
Step 01) Add the code bellow in base.html.twig from theme.  
  
Note: See in the end of article the meta tags for title and description too.

Quote:

  

  
Step 02: Create a folder called "LandingPages" in the Mautic FileManager  
  
Step 03: Add the pictures [facebook] and [twitter] in the folder LandingPages with the follow structure.  
Replace the XX for the LandingPage ID according to Mautic.  
XX\_banner\_twitter.png  
XX\_banner\_facebook.png  
  
Additional information: Meta tags for title and description too.

Quote:

---

<div class="post-metadata">

**Author:** ![Lucas](https://avatars.discourse-cdn.com/v4/letter/l/ba8739/32.png) [@Lucas](https://forum.mautic.org/u/Lucas)\
**Post date:** [October 13, 2017, 4:52pm UTC](https://forum.mautic.org/t/adding-add-facebook-and-twitter-image-meta-tags-dynamically-in-landing-page/9691/2 "2017-10-13T16:52:40Z")

</div>

Just sharing one way to add facebook and twitter image meta tags dynamically in landing page:

Step 01) Add the code bellow in base.html.twig from theme.  
Note: See in the end of article the meta tags for title and description too.

> [@](#):
>
> \<meta name=“twitter:image” content=“{{ app.request.getSchemeAndHttpHost() }}/media/images/landingpages/{{ app.request.getPathInfo() | replace({‘/s/pages/builder/’: “”}) }}\_banner\_twitter.png”\>  
> \<meta property=“og:image” content=“{{ app.request.getSchemeAndHttpHost() }}/media/images/landingpages/{{ app.request.getPathInfo() | replace({‘/s/pages/builder/’: “”}) }}\_banner\_facebook.png”\>

Step 02: Create a folder called “LandingPages” in the Mautic FileManager

Step 03: Add the pictures [facebook] and [twitter] in the folder LandingPages with the follow structure.  
Replace the XX for the LandingPage ID according to Mautic.  
XX\_banner\_twitter.png  
XX\_banner\_facebook.png

Additional information: Meta tags for title and description too.

> [@](#):
>

---

<div class="post-metadata">

**Author:** ![Huckleberry](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/huckleberry/32/535_2.png) [@Huckleberry](https://forum.mautic.org/u/Huckleberry)\
**Post date:** [November 30, 2017, 3:36pm UTC](https://forum.mautic.org/t/adding-add-facebook-and-twitter-image-meta-tags-dynamically-in-landing-page/9691/3 "2017-11-30T15:36:39Z")

</div>

This is great!  
However, it’s a little techy for the average person to understand.  
Would it be possible to check if the files exist, and if not, to default to a logo file or something?  
I can wrap my head around it in PHP, and partly in twig, but can’t figure out how to actually check if it exists correctly in twig.  
Any ideas?  
Thanks for sharing the excellent code, this should be a standard added to Mautic, right up there with UTM tags that did get implemented.

---

<div class="post-metadata">

**Author:** ![Huckleberry](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/huckleberry/32/535_2.png) [@Huckleberry](https://forum.mautic.org/u/Huckleberry)\
**Post date:** [December 1, 2017, 2:50am UTC](https://forum.mautic.org/t/adding-add-facebook-and-twitter-image-meta-tags-dynamically-in-landing-page/9691/4 "2017-12-01T02:50:48Z")

</div>

Did a little thinking. Got the simplest solution I think—do it via .htaccess at the server level!

Simply create a new .htaccess file in the folder where you store the Facebook and Twitter images.  
In that file enter the following. And ta-da, your default image can be set on the last line.

```auto
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ Default-Image.png [NC,L]
```
