Velo: About SEO and Routing

Visit the Velo by Wix website to onboard and continue learning.

SEO Settings for router pages vary slightly from the settings for regular pages. Learn about SEO for Wix pages here.

You can define the page title, description, and social network images for router pages just like you can for regular pages. The difference is that since router pages do not contain static data, their SEO information must be set dynamically, so they reflect the real content they will hold when they are viewed.

There are two parts to setting up SEO on your router pages:

  • Create meta tags for Google to learn about your pages.
  • Create a sitemap for Google to use to find your pages.

Meta Tags

You set SEO meta tags for your router's pages when you create the router's router() function. Within that function, you create a HeadOptions object and pass it to the page you route to using the ok() function.

For example, in the sample code that is provided when you add a router, the following code uses the data retrieved by the router to build a HeadOptions object and pass it to the page named myRouter-page.

Copy
1
export function myRouter_Router(request) {
2
3
// retrieve data for the page ...
4
5
let seoData = {
6
title: data.title,
7
description: "This is a description of " + data.title + " page",
8
noIndex: false,
9
metaTags: {
10
"og:title": data.title,
11
"og:image": data.image
12
}
13
};
14
15
return ok("myRouter-page", data, seoData);
16
17
//...
18
}

The HeadOptions object contains several properties that you can set with relevant values using the data you retrieve in your router() function. The title and description properties contain the page's title and description that are used for SEO purposes. The object can also contain a noIndex flag that tells Google whether it should index your page. Additional meta tags can be added to the metaTags property.

The HeadOptions object can also contain a keywords property, but Google ignores your site's keywords.

Sitemap

Your site's sitemap is what Google uses to find all your site's pages. Pages on your site that don't belong to a router are added to your site's sitemap for you. However, since you fully control what pages are available through your router, including all of their dynamically different versions, you need to create a sitemap that contains all possible URLs that are connected to your router's prefix so Google can find them.

To add your router's pages to your site's sitemap, you create a sitemap() function for the router. Within that function, you create a WixRouterSitemapEntry object for each URL the router can possibly route to. Each WixRouterSitemapEntry includes information about a page, such as its URL, title, and name. You can also add additional information about each page, such as how often its content changes, when the last change was, and its relative priority within your site. Google uses the sitemap entries to discover all the pages in your site.

For example, in the sample code that is provided when you add a router, the following code uses the data retrieved by the router to build a HeadOptions object and pass it to the page named myRouter-page.

Copy
1
export function myRouter_SiteMap(sitemapRequest) {
2
3
//Convert the data to site map entries
4
let siteMapEntries = Object.keys(peopleData).map( (name) => {
5
const data= peopleData[name];
6
let entry = new WixRouterSitemapEntry(name);
7
entry.pageName = "myRouter-page";
8
entry.url = "/myRouter/" + name ;
9
entry.title = data.title;
10
return entry;
11
} );
12
13
// Wrap in asynchronic Promise
14
return Promise.resolve(siteMapEntries);
15
}

To ensure that your sitemap is working properly, you can get the sitemap from your published site. In a web browser, go to your published site's URL and append /sitemap.xml to it. 

For example, for premium sites, if your site's published URL is:

**https://mysite.com** 

Go to:

https://mysite.com/sitemap.xml  

For free sites, if your site's published URL is:

https://username.wixsite.com/site-name

Go to:

https://username.wixsite.com/site-name/sitemap.xml

Was this helpful?
Yes
No