This article explains how to configure SEO for your router pages. There are two parts to setting up the SEO:
You set SEO meta tags for your router's pages in the router()
function in routers.js
:
Within the router()
function, create an object that contains your desired SEO settings. This will become the HeadOptions
object that you pass to the router page.
Use the provided sample code in the router()
function as a starting point:
The example object contains several properties that are set using the data it retrieves in the router()
function, including the following:
The title
property, which contains the page’s SEO title.
The description
property, which contains a short description of the page’s content.
A noIndex
flag, set to false
. This tells Google that it should index your page.
Additional meta tags contained in the 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.
Once you’ve created your HeadOptions
object, pass it to the ok()
function as the third parameter. This object is then sent to the router page so that Google has SEO information for it.
This sample code shows an example of passing the HeadOptions
object defined above to myRouter-page:
To add your router pages to your sitemap, do the following:
In your router’s sitemap()
function, create a WixRouterSitemapEntry
object for each URL the router can possibly route to. Use the sample code added to your first sitemap()
function as a starting point:
Each WixRouterSitemapEntry
in the example includes the router page’s URL, title, and name. The example code groups them into an array.
Return all the sitemap entries to create the router sitemap. Again, you can follow the example in the sample code:
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 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
.
Check that the sitemap matches the layout of your router pages.