This article demonstrates how to configure SEO for your router pages. There are 2 parts to setting up the SEO:
Note: Routers currently require Velo APIs and file naming conventions. While you can use the JavaScript SDK alongside Velo for data operations and logic, router handlers must be defined using Velo syntax in the routers.js backend file.
To set SEO meta tags for your router's pages:
In your router.js file, create an object that contains your desired SEO settings inside the router() function. This becomes the HeadOptions object that you pass to the router page.
The sample code below contains several properties that are set using the data it retrieves in the router() function, including the following:
title property, which contains the page's SEO title.description property, which contains a short description of the page's content.noIndex flag, set to false. This tells Google that it should index your page.metaTags property. You can add meta tags to this property.Keep or remove these properties, and add your own as needed.
Note: The HeadOptions object can also contain a keywords property, but Google ignores your site's keywords.
Specify the HeadOptions object as the third parameter in the ok() function. This object is then sent to the router page so that Google has SEO information for it.
To add your router pages to your sitemap:
In your router's sitemap() function, create a WixRouterSitemapEntry object for each URL the router can possibly route to.
Each WixRouterSitemapEntry in the code example below includes the router page's URL, title, and name. The example groups them into an array.
Return all the sitemap entries to create the router sitemap. For example:
To ensure that your sitemap is working properly, you can get the sitemap from your published site:
In your web browser, go to your published site's URL and append /sitemap.xml to it.
https://mysite.com, go to: https://mysite.com/sitemap.xml.https://username.wixsite.com/site-name, go to https://username.wixsite.com/site-name/sitemap.xml.Check that the sitemap matches the layout of your router pages.