Gridsome: Add support for static urls in sitemap module

Created on 28 Apr 2019  路  3Comments  路  Source: gridsome/gridsome

Summary

Right now the sitemap module can only add entries for pages that are generated with Gridsome. It would be great to have an option to add static URLs like images and videos.

Basic example

Example from the sitemap.js docs

url: 'http://test.com/page-1/',
img: [
  {
    url: 'http://test.com/img1.jpg',
    caption: 'An image',
    title: 'The Title of Image One',
    geoLocation: 'London, United Kingdom',
    license: 'https://creativecommons.org/licenses/by/4.0/'
  },
  {
    url: 'http://test.com/img2.jpg',
    caption: 'Another image',
    title: 'The Title of Image Two',
    geoLocation: 'London, United Kingdom',
    license: 'https://creativecommons.org/licenses/by/4.0/'
  }
]
}]

A way to handle this would be to add a staticUrls property in the config of the stitemap modulde:

  plugins: [
    {
      use: '@gridsome/plugin-sitemap',
      options: {
        config: {
          staticUrls: [
            {
              url: '/images/',
              img: [
                {
                  url: '/images/img1.jpg',
                  caption: 'An image',
                  title: 'The Title of Image One',
                  geoLocation: 'London, United Kingdom',
                }
              ]
            }
          ]
        }
      }
    }
  ]

Motivation

Sometimes you need to add static URLs to the sitemap for SEO.

Edit:
Maybe a options.staticUrls is better?

plugins: [
  {
    use: '@gridsome/plugin-sitemap',
    options: {
      staticUrls: [
        {
          url: '/images/',
          img: [
            {
              url: '/images/img1.jpg',
              caption: 'An image',
              title: 'The Title of Image One',
              geoLocation: 'London, United Kingdom',
            }
          ]
        }
      ],
      config: {
        // rest of config here
      }
    }
  }
]
feature request

Most helpful comment

Thanks a lot for the request and commits! :tada: :smile: @ameistad if you're finished, or ready for feedback, could you please make a PR out of this?

All 3 comments

Just so you know your work here is appreciated, I merged your pull request on my fork, got it available via verdaccio, and started to try it out via a build.

Unfortunately something about the current state of master scrambled the router or its connection to vuetify menus, so had to put it back as must advance the underlying project. Afterwards I mused on what I might have forgotten, such as pulling also state of other plugins from the fork...probably just something like that. But an interesting expedition, and looking forward to the static urls for sure in a release! In my case, I'd like to put some vuepress doc under one.

Thanks a lot for the request and commits! :tada: :smile: @ameistad if you're finished, or ready for feedback, could you please make a PR out of this?

PR was merged (#392).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kaceo picture kaceo  路  3Comments

realtebo picture realtebo  路  3Comments

tomtev picture tomtev  路  3Comments

tanc picture tanc  路  3Comments

upandfine picture upandfine  路  3Comments