Search.../

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