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.

Because you want the links you set to be read by search engines, you should always set them in the onReady() event handler.

The links you set overwrite any link information set earlier.

Note: 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

Code Example

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