Search.../

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:

{
"property": "og:image",
"content": "https://.../Wix+logo.jpg"
}
javascript | Copy Code

Produces:

<meta property="og:image" content="https://.../Wix+logo.jpg"/>
html | Copy Code

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 the setTitle() function instead.

  • You should always set the metaTags inside the onReady() event handler to ensure search engines can read it.

Syntax

function setMetaTags(metaTags: Array<MetaTag>): Promise<void>

setMetaTags Parameters

NAME
TYPE
DESCRIPTION
metaTags
Array<MetaTag>

The meta tags to set.

Returns

Fulfilled - When the meta tags are set.

Return Type:

Promise<void>

Related Content:

Was this helpful?

Set a page's meta tags

Copy Code
1import wixSeoFrontend from 'wix-seo-frontend';
2
3// ...
4
5$w.onReady( () => {
6 wixSeoFrontend.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} );