setMetaTags( )
Sets the page's SEO-related meta tags.
Description
The setMetaTags()
function creates SEO-related meta tags in the head of the page.
The keys in the specified metaTags
objects represent the keys in the tag, while the values in the
metaTags
object represent the values in the tag.
For example:
javascript | Copy Code{"property": "og:image","content": "https://.../Wix+logo.jpg"}
Produces:
html | Copy Code<meta property="og:image" content="https://.../Wix+logo.jpg"/>
When setting og:image
meta tags, the content
can be and external image URL
or a Media Manager image URL as described here.
The meta tags you set overwrite any meta tag information set earlier.
Notes:
Do not use
setMetaTags()
to create tags for the title. Use thesetTitle()
function instead.You should always set the
metaTags
inside theonReady()
event handler to ensure search engines can read it.
Syntax
function setMetaTags(metaTags: Array<MetaTag>): Promise<void>
setMetaTags Parameters
NAME
TYPE
DESCRIPTION
The meta tags to set.
Returns
Fulfilled - When the meta tags are set.
Return Type:
Related Content:
Was this helpful?
Set a page's meta tags
1import wixSeo from 'wix-seo';23// ...45$w.onReady( () => {6 wixSeo.setMetaTags(7 [8 {9 "name": "robots",10 "content": "noindex"11 }, {12 "property": "og:image",13 "content": "wix:image://v1/6...2.jpg/a.jpg#originWidth=970&originHeight=120"14 }15 ]16 )17 .then( () => {18 console.log("meta tags set");19 } )20 .catch( () => {21 console.log("failed setting meta tags");22 } );23} );