gatsby-plugin-sitemap URL priorities

Created on 12 Jun 2018  路  4Comments  路  Source: gatsbyjs/gatsby

Summary

I am not sure where the best / default place is to enter priorities for the sitemap.xml URLs.
gatsby-plugin-sitemap itself does not provide for an option to set priorities. The gatsby-plugin-sitemap documentation reads

The defaultOptions here can be overridden.

but I think it is not kind of obvious how the change for the individual URL priorities is supposed to be done.

For the time being I am using the solution below, which is based on the current source, but it does not really look convincing.

If this is how it is supposed to be done, I am happy to PR this to the gatsby-plugin-sitemap docs.

Relevant information

gatsby-config.js:

    // ...
    {
      resolve: `gatsby-plugin-sitemap`,
      options: {
        serialize: ({ site, allSitePage }) =>
          allSitePage.edges.map(edge => {
            let path = edge.node.path
            let priority = 0.5
            if (path.match(/products/)) {
              priority = 1.0
            } else if (path.match(/production/)) {
              priority = 0.9
            } else if (path.match(/about/)) {
              priority = 0.8
            } else if (path.match(/contact/)) {
              priority = 0.7
            } else if (path.match(/blog/)) {
              priority = 0.4
            } else if (path.match(/imprint/)) {
              priority = 0.3
            } else if (path.match(/data-protection/)) {
              priority = 0.2
            }
            console.log("priority: ", priority.toFixed(1), "    path: ", path)
            return {
              url: site.siteMetadata.siteUrl + edge.node.path,
              changefreq: `monthly`,
              priority
            }
          })
      }
    },
    // ...
stale? documentation

Most helpful comment

Hey @karland, adding this to the docs seems like a good first step? A PR would be very welcome!

If there's a lot of demand for handling priorities within the plugin itself, we could update the plugin at a later time.

All 4 comments

FYI, Google don't care about priority in sitemap

Hey @karland, adding this to the docs seems like a good first step? A PR would be very welcome!

If there's a lot of demand for handling priorities within the plugin itself, we could update the plugin at a later time.

Old issues will be closed after 30 days of inactivity. This issue has been quiet for 20 days and is being marked as stale. Reply here or add the label "not stale" to keep this issue open!

This issue is being closed due to inactivity. Is this a mistake? Please re-open this issue or create a new issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

andykais picture andykais  路  3Comments

timbrandin picture timbrandin  路  3Comments

benstr picture benstr  路  3Comments

brandonmp picture brandonmp  路  3Comments

hobochild picture hobochild  路  3Comments