+ Start a Discussion
Ken KoellnerKen Koellner 

I need to put a meta tag inside the <head> </head> area of a VF page.

Anyone know a way to put a <meta .../> tag in the <head> </head> area of a page rendered by VF?

If I just include meta tag I need -- <meta name="viewport" content="width=device-width, initial-scale=1.0"/> after the <apex:page  .../> tag, it comes out in the body when VF renders the page.  Even with standard styles off.



 
Vasani ParthVasani Parth
Hi Ken,

Here's the sample code for you,
 
<apex:page sidebar="false" showHeader="false" standardStylesheets="false" cache="false">
    <html>
        <head>
            <meta http-equiv="refresh" content="3;URL=http://www.google.com"/>
        </head>
        <body>
            <h1>Thanks</h1>
        </body>
    </html>
</apex:page>

Please mark this as the best asnwer if this helps
Chris  ByromChris Byrom
You actually need something slightly different for this to work properly.
 
<apex:page sidebar="false" showHeader="false" standardStylesheets="false" cache="false" applyHtmlTag="false">
    <html>
        <head>
            <meta http-equiv="refresh" content="3;URL=http://www.google.com"/>
        </head>
        <body>
            <h1>Thanks</h1>
        </body>
    </html>
</apex:page>

The applyHtmlTag and applyBodyTag options control whether or not SF generates them. Without them set to false, adding your own <html> and <head> tags results in duplicates. If you create a page with Vasani's example and this one, you can see the difference. Again, if you want your own <body> tag set applyBodyTag to false and it won't generate it either. 

More info here:

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_page.htm