Search.../

wix-seo-frontend

The wix-seo-frontend module contains functionality for working with your site's SEO from client-side code. Learn more.

Guides

Additional information about this section

Properties

Store values associated with an object

  • links
  • metaTags
  • structuredData
  • title
Functions

Perform actions on an object

Introduction

To use the SEO API, import wixSeoFrontend from the wix-seo-frontend module:

import wixSeoFrontend from 'wix-seo-frontend';
javascript | Copy Code

Was this helpful?

links

Gets the page's SEO-related link tags.

Description

Use the links property to get a page's SEO-related link tags which provide additional SEO information about your page. For example, the tags may contain a link to a canonical or alternate version of the current page.

Note: You should always invoke the wixSeoFrontend.links getter outside of the onReady() event handler to ensure receiving the proper response.

Type:

Array<Link>Read Only
NAME
TYPE
DESCRIPTION
rel
string

The relationship of the linked resource to the current page.

href
string

The URL of the linked resource.

Related Content:

Was this helpful?

Get a page's link tags

Copy Code
1import wixSeoFrontend from 'wix-seo-frontend';
2
3// ...
4
5let links = wixSeoFrontend.links;
6
7/* links:
8 *
9 * [
10 * {
11 * "rel": "canonical",
12 * "href": "http://mysite.com/canonical_version"
13 * }, {
14 * "rel": "author",
15 * "href": "http://mysite.com/janedoe"
16 * }
17 * ]
18 */

metaTags

Gets the page's SEO-related meta tags.

Description

The metaTags property retrieves the SEO-related meta tags from the head of the page.

The keys in the returned metaTags objects represent the keys in the tag, while the values in the 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

Note: You should always invoke the wixSeoFrontend.metaTags getter outside of the onReady() event handler to ensure receiving the proper response.

Type:

Array<MetaTag>Read Only
NAME
TYPE
DESCRIPTION
name
string

Name of the meta tag. Either name or property are required.

property
string

Name of the meta tag property. Either property or name are required.

http-equiv
string

HTTP header that corresponds to the content.

content
string

Meta tag value. For og:image meta tags, the content can be an external image URL or a Media Manager image URL as described here.

Related Content:

Was this helpful?

Get a page's meta tags

Copy Code
1import wixSeoFrontend from 'wix-seo-frontend';
2
3// ...
4
5let metaTags = wixSeoFrontend.metaTags;
6
7/* metaTags:
8 *
9 * [
10 * {
11 * "name": "robots",
12 * "content": "noindex"
13 * }, {
14 * "property": "og:image",
15 * "content": "wix:image://v1/6...2.jpg/a.jpg#originWidth=970&originHeight=120"
16 * }
17 * ]
18 */

structuredData

Gets the page's structured data.

Description

The structured data on your page helps search engines understand more about your page and your business so they can display a richer snippet of your pages in search results.

Set the structured data with a list of structured data objects in the JSON-LD format as defined by schema.org.

Note: You should always invoke the wixSeoFrontend.structuredData getter outside of the onReady() event handler to ensure receiving the proper response.

Type:

Array<Object>Read Only

Related Content:

Was this helpful?

Get a page's structured data

Copy Code
1import wixSeoFrontend from 'wix-seo-frontend';
2
3// ...
4
5let structuredData = wixSeoFrontend.structuredData;
6
7/* structuredData:
8 *
9 * [
10 * {
11 * "@context": "http://schema.org",
12 * "@type": "Organization",
13 * "name": "My Organization Name",
14 * "url": "https://www.myorgdomain.com"
15 * },
16 * {
17 * "@context": "http://schema.org",
18 * "@type": "Person",
19 * "email": "mailto:john.doe@somedomain.com",
20 * "jobTitle": "Professor",
21 * "name": "John Doe",
22 * "telephone": "(555) 555-555"
23 * }
24 * ]
25 */

title

Gets the page's title.

Description

The title is an important factor that lets search engines determine the topic of a page.

Note: You should always invoke the wixSeoFrontend.title getter outside of the onReady() event handler to ensure receiving the proper response.

Type:

stringRead Only

Related Content:

Was this helpful?

Get the SEO title

Copy Code
1import wixSeoFrontend from 'wix-seo-frontend';
2
3// ...
4
5let title = wixSeoFrontend.title; // "Page Title"

setLinks( )

Sets the page's SEO-related link tags.

Description

Use the setLinks() function to set a page's SEO-related link tags which provide additional SEO information about your page. For example, you can set a link to a canonical or alternate version of the current page.

The links you set overwrite any link information set earlier.

Notes:

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

  • You cannot add a stylesheet link using the setLinks function.

Syntax

function setLinks(links: Array<Link>): Promise<void>

setLinks Parameters

NAME
TYPE
DESCRIPTION
links
Array<Link>

The links to set.

Returns

Fulfilled - When the link tags are set.

Return Type:

Promise<void>

Related Content:

Was this helpful?

Get a page's link tags

Copy Code
1import wixSeoFrontend from 'wix-seo-frontend';
2
3// ...
4
5$w.onReady( () => {
6 wixSeoFrontend.setLinks(
7 [
8 {
9 "rel": "canonical",
10 "href": "http://mysite.com/cononical_version"
11 }, {
12 "rel": "author",
13 "href": "http://mysite.com/janedoe"
14 }
15 ]
16 )
17 .then( () => {
18 console.log("links set");
19 } )
20 .catch( () => {
21 console.log("failed setting links");
22 } );
23} );

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} );

setStructuredData( )

Sets the page's structured data.

Description

The structured data on your page helps search engines understand more about your page and your business so they can display a richer snippet of your pages in search results.

The structured data you set overwrites any structured data information set earlier.

Note: You should always set the structured data inside the onReady() event handler to ensure search engines can read it.

Syntax

function setStructuredData(structuredData: Array<Object>): Promise<void>

setStructuredData Parameters

NAME
TYPE
DESCRIPTION
structuredData
Array<Object>

List of structured data objects in the JSON-LD format as defined by schema.org.

Returns

Fulfilled - When the structured data is set.

Return Type:

Promise<void>

Related Content:

Was this helpful?

Set a page's structured data

Copy Code
1import wixSeoFrontend from 'wix-seo-frontend';
2
3// ...
4
5$w.onReady( () => {
6 wixSeoFrontend.setStructuredData(
7 [
8 {
9 "@context": "http://schema.org",
10 "@type": "Organization",
11 "name": "My Organization Name",
12 "url": "https://www.myorgdomain.com"
13 },
14 {
15 "@context": "http://schema.org",
16 "@type": "Person",
17 "email": "mailto:john.doe@somedomain.com",
18 "jobTitle": "Professor",
19 "name": "John Doe",
20 "telephone": "(555) 555-555"
21 }
22 ]
23 )
24 .then( () => {
25 console.log("structured data set");
26 } )
27 .catch( () => {
28 console.log("failed setting structured data");
29 } );
30} );

setTitle( )

Sets the page's title.

Description

Setting a proper title is important to let search engines determine the topic of your page.

Note: You should always set the title inside the onReady() event handler to ensure search engines can read it.

Syntax

function setTitle(title: string): Promise<void>

setTitle Parameters

NAME
TYPE
DESCRIPTION
title
string

The title to set.

Returns

Fulfilled - When the title is set.

Return Type:

Promise<void>

Related Content:

Was this helpful?

Set a page's SEO title

Copy Code
1import wixSeoFrontend from 'wix-seo-frontend';
2
3// ...
4
5$w.onReady( () => {
6 wixSeoFrontend.setTitle("New Title")
7 .then( () => {
8 console.log("title set");
9 } )
10 .catch( () => {
11 console.log("failed setting title");
12 } );
13
14} );