Coder Social home page Coder Social logo

pluginpal / strapi-plugin-sitemap Goto Github PK

View Code? Open in Web Editor NEW
241.0 5.0 51.0 1.69 MB

πŸ”Œ Generate a highly customizable sitemap XML in Strapi CMS

Home Page: https://www.pluginpal.io/plugin/sitemap

License: MIT License

JavaScript 92.40% XSLT 4.29% CSS 1.07% HTML 1.13% TypeScript 1.12%
strapi plugin sitemap seo uid strapi-plugin strapi-plugin-sitemap

strapi-plugin-sitemap's Introduction

Strapi sitemap plugin

Create a highly customizable sitemap XML in Strapi CMS.

NPM Version Monthly download on NPM CI build status codecov.io

✨ Features

  • Multilingual (Implements rel="alternate" with @strapi/plugin-i18n)
  • URL bundles (Bundle URLs by type and add them to the sitemap XML)
  • Dynamic paths (Implements URL patterns in which you can inject dynamic fields)
  • Virtual sitemap (Sitemaps served from the database)
  • Cron regeneration (Automatically scheduled cron job for regeneration)
  • Sitemap indexes (Paginated sitemap indexes for large URL sets)
  • Exclude URLs (Exclude specified URLs from the sitemap)
  • Custom URLs (URLs of pages which are not managed in Strapi)
  • CLI (CLI for sitemap generation)
  • Styled with XSL (Human readable XML styling)

⏳ Installation

Install the plugin in your Strapi project.

# using yarn
yarn add strapi-plugin-sitemap

# using npm
npm install strapi-plugin-sitemap --save

After successful installation you have to rebuild the admin UI so it'll include this plugin. To rebuild and restart Strapi run:

# using yarn
yarn build
yarn develop

# using npm
npm run build
npm run develop

The Sitemap plugin should now appear in the Settings section of your Strapi app.

Enjoy πŸŽ‰

πŸ– Requirements

Complete installation requirements are the exact same as for Strapi itself and can be found in the Strapi documentation.

Supported Strapi versions:

  • Strapi ^4.11.4 (use strapi-plugin-sitemap@^3)
  • Strapi ^4.5.x (use strapi-plugin-sitemap@^2)

(This plugin may work with older Strapi versions, but these are not tested nor officially supported.)

We recommend always using the latest version of Strapi to start your new projects.

πŸ’‘ Usage

With this plugin you have full control over which URLs you add to your sitemap XML. Go to the admin section of the plugin and start adding URLs. Here you will find that there are two ways to add URLs to the sitemap. With URL bundles and Custom URLs.

URL bundles

A URL bundle is a set of URLs grouped by type. When adding a URL bundle to the sitemap you can define a URL pattern which will be used to generate all URLs in this bundle. (Read more about URL patterns below)

URLs coming from a URL bundle will get the following XML attributes:

  • <loc>
  • <lastmod>
  • <priority>
  • <changefreq>

Custom URLs

A custom URL is meant to add URLs to the sitemap which are not managed in Strapi. It might be that you have custom route like /account that is hardcoded in your front-end. If you'd want to add such a route (URL) to the sitemap you can add it as a custom URL.

Custom URLs will get the following XML attributes:

  • <loc>
  • <priority>
  • <changefreq>

πŸ”Œ URL pattern

To create dynamic URLs this plugin uses URL patterns. A URL pattern is used when adding URL bundles to the sitemap and has the following format:

/pages/[category.slug]/[my-uid-field]

Fields can be injected in the pattern by escaping them with [].

Also relations can be queried in the pattern like so: [relation.fieldname].

The following field types are by default allowed in a pattern:

  • id
  • uid

Allowed field types can be altered with the allowedFields config. Read more about it below.

🌍 Multilingual

When adding a URL bundle of a type which has localizations enabled you will be presented with a language dropdown in the settings form. You can now set a different URL pattern for each language.

For each localization of a page the <url> in the sitemap XML will get an extra attribute:

  • <xhtml:link rel="alternate">

This implementation is based on Google's guidelines on localized sitemaps.

πŸ”— Sitemap index

Large sitemaps (larger then 45.000 urls) will automatically be split up in to seperate sitemaps.
A sitemap index will be created that links to all the different sitemap chunks.
That sitemap index will be accessible on the default /api/sitemap/index.xml location.

It is required to set the url in the ./config/server.js file in your Strapi installation. That will be used to create the links to the different chunks.

You can alter the 45.000 magic number through plugin config.

πŸ€– Robots.txt

To make sure search engines are able to find the sitemap XML create a robots.txt file in the front-end of your website and add the following line:

Sitemap: https://your-strapi-domain.com/api/sitemap/index.xml

Read more about the robots.txt file here.

πŸ“Ί CLI

This plugin comes with it's own strapi-sitemap CLI. You can add it to your project like so:

"scripts": {
  // ...
  "sitemap": "strapi-sitemap"
},

You can now run the generate command like so:

# using yarn
yarn sitemap generate

# using npm
npm run sitemap generate

βš™οΈ Settings

Settings can be changed in the admin section of the plugin. In the last tab (Settings) you will find the settings as described below.

Hostname (required)

The hostname is the URL of your website. It will be used as the base URL of all URLs added to the sitemap XML. It is required to generate the XML file.

Key: hostname

required: YES | type: string | default: ''

Hostname overrides

If you are using this plugin in a multilingual Strapi project you will be presented with a 'Hostname overrides' setting. With this setting you can set a specific hostname per language.

This is handy for when you have a URL structure like this:

Key: hostname_overrides

required: NO | type: object | default: {}

Exclude drafts

When using the draft/publish functionality in Strapi this setting will make sure that all draft pages are excluded from the sitemap. If you want to have the draft pages in the sitemap anyways you can disable this setting.

Key: excludeDrafts

required: NO | type: bool | default: true

Include homepage

This setting will add a default / entry to the sitemap XML when none is present. The / entry corresponds to the homepage of your website.

Key: includeHomepage

required: NO | type: bool | default: true

Default language URL (x-default)

This setting will add an additionnal <link /> tag into each sitemap urls bundles with value hreflang="x-default" and the path of your choice. The hreflang x-default value is used to specify the language and region neutral URL for a piece of content when the site doesn't support the user's language and region. For example, if a page has hreflang annotations for English and Spanish versions of a page along with an x-default value pointing to the English version, French speaking users are sent to the English version of the page due to the x-default annotation. The x-default page can be a language and country selector page, the page where you redirect users when you have no content for their region, or just the version of the content that you consider default.

Key: defaultLanguageUrlType

required: NO | type: string | default: ''

πŸ”§ Config

Config can be changed in the config/plugins.js file in your Strapi project. You can overwrite the config like so:

module.exports = ({ env }) => ({
  // ...
  'sitemap': {
    enabled: true,
    config: {
      cron: '0 0 0 * * *',
      limit: 45000,
      xsl: true,
      autoGenerate: false,
      caching: true,
      allowedFields: ['id', 'uid'],
      excludedTypes: [],
    },
  },
});

CRON

To make sure the sitemap stays up-to-date this plugin will automatically schedule a cron job that generates the sitemap for you. That cron job is configured to run once a day at 00:00.

If you want to change the cron interval you can alter the cron setting.

Key: cron

required: NO | type: bool | default: 0 0 0 * * *

Limit

When creating large sitemaps (50.000+ URLs) you might want to split the sitemap in to chunks that you bring together in a sitemap index.

The limit is there to specify the maximum amount of URL a single sitemap may hold. If you try to add more URLs to a single sitemap.xml it will automatically be split up in to chunks which are brought together in a single sitemap index.

Key: limit

required: NO | type: int | default: 45000

XSL

This plugin ships with some XSL files to make your sitemaps human readable. It adds some styling and does some reordering of the links.

These changes are by no means a requirement for your sitemap to be valid. It is really just there to make your sitemap look pretty.

If you have a large sitemap you might encounter performance issues when accessing the sitemap.xml from the browser. In that case you can disable the XSL to fix these issues.

Key: xsl

required: NO | type: bool | default: true

Auto generate

Alternatively to using cron to regenerate your sitemap, this plugin offers an automatic generation feature that will generate the sitemap through lifecycle methods. On create, update and delete this plugin will do a full sitemap regeneration. This way your sitemap will always be up-to-date when making content changes.

If you have a large sitemap the regeneration becomes an expensive task. Because of that this setting is disabled by default and it is not recommended to enable it for sitemaps with more than 1000 links.

Also the search engines don't even crawl your sitemap that often, so generating it once a day through cron should be suffecient.

Key: autoGenerate

required: NO | type: bool | default: false

Caching

This setting works together with the autoGenerate setting. When enabled a JSON representation of the current sitemap will be stored in the database. Then, whenever the sitemap is being regenerated through lifecycles, the cache will be queried to build the sitemap instead of querying all individual (unchanged) pages.

Key: caching

required: NO | type: bool | default: true

Allowed fields

When defining a URL pattern you can populate it with dynamic fields. The fields allowed in the pattern can be manipulated with this setting. Fields can be specified either by type or by name. By default the plugin allows id and uid.

If you are missing a key field type of which you think it should be allowed by default please create an issue and explain why it is needed.

Key: allowedFields

required: NO | type: array | default: ['id', 'uid']

Excluded types

This setting is just here for mere convenience. When adding a URL bundle to the sitemap you can specify the type for the bundle. This will show all types in Strapi, however some types should never be it's own page in a website and are therefor excluded in this setting.

All types in this array will not be shown as an option when selecting the type of a URL bundle.

The format of the types should look something like api::test.api. To see all the types you can choose from, run strapi content-types:list.

Key: excludedTypes

required: NO | type: array

🀝 Contributing

Feel free to fork and make a pull request of this plugin. All the input is welcome!

⭐️ Show your support

Give a star if this project helped you.

πŸ”— Links

🌎 Community support

πŸ“ Resources

strapi-plugin-sitemap's People

Contributors

boazpoolman avatar daveskybetbot avatar dependabot[bot] avatar higherror avatar ilnytskyi avatar kahrpatrick avatar kibblerz avatar mattwcole avatar melishev avatar msacc avatar pr0gr8mm3r avatar romaingueffier avatar tmclouisluk avatar tripss avatar yasudacloud avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

strapi-plugin-sitemap's Issues

Some collection types are not been rendering in the sitemap

I'm using this plugin at a sitemap in my site, but I get a bug:

I set all collection types in the settings:
Screen Capture_select-area_20201129164905

As can be seen, both Tags and Categories are collection types with a valid UID field(slug), but, navigation to the site map, we get this:

<url>
        <loc>https://localhost/pages/education</loc>
        <lastmod>2020-10-20T12:08:32.430Z</lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.8</priority>
    </url>
    <url>
        <loc>https://localhost/pages/work-experience</loc>
        <lastmod>2020-10-31T13:42:22.293Z</lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.8</priority>
    </url>
    <url>
        <loc>https://localhost/pages/about-me</loc>
        <lastmod>2020-10-20T12:42:11.136Z</lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.8</priority>
    </url>
    <url>
        <loc>https://localhost/pages/projects</loc>
        <lastmod>2020-10-18T22:47:14.513Z</lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.8</priority>
    </url>
    <url>
        <loc>https://localhost/pages/posts</loc>
        <lastmod>2020-10-18T22:47:14.658Z</lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.8</priority>
    </url>
    <url>
        <loc>https://localhost/pages/read-the-documentation-fool</loc>
        <lastmod>2020-11-01T14:22:39.533Z</lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.8</priority>
    </url>
    <url>
        <loc>https://localhost/pages/grid-and-flex-layout-making-responsiveness-handling-easier</loc>
        <lastmod>2020-11-01T14:31:31.554Z</lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.8</priority>
    </url>
    <url>
        <loc>https://localhost/pages/home</loc>
        <lastmod>2020-11-01T13:16:42.930Z</lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.8</priority>
    </url>
    <url>
        <loc>https://localhost/</loc>
        <changefreq>monthly</changefreq>
        <priority>1.0</priority>
    </url>

No trace of tags or categories, even though there are at least five records in each.

I tested this both in local and production but i am getting the same result. I thought it could be because of the draft system, but both tags and categories do not use this feature.

What could be the problem then?

PD: there is also another collection type which not use a uid field but i would like to add to the sitemap, is there any way to do that?

Thanks

Generate sitemap when server boots

Feature request

Summary

To generate a sitemap when the server boots

Why is it needed?

We run Strapi in Google Cloud Run, these scale to zero so now sometimes when we retrieve the sitemap it does not exist, creating one on boot would solve this.

Suggested solution(s)

When the server boots to also create an sitemap.

Related issue(s)/PR(s)

#84

Batched sitemap generation

Feature request

Summary

Generate the sitemap XML in batches.

Why is it needed?

So that you Strapi app won’t timeout when you are tryinh to build a sitemap with a lot URLs.

Suggested solution(s)

Register some kind of queue of batches where each batch would add e.g. 10.000 URLs to the sitemap. This queue will then run in the background.

Related issue(s)/PR(s)

#83

[BUG] Error with Strapi 4.3.2

Bug report

Describe the bug

Somehow, when trying to get into the Sitemap view we are getting this problem:

[2022-08-07 23:30:00.122] error: [strapi-plugin-sitemap]: Something went wrong while trying to build the SitemapStream. TypeError [ERR_INVALID_URL]: Invalid URL: 
[2022-08-07 23:31:00.132] error: [strapi-plugin-sitemap]: Something went wrong while trying to build the SitemapStream. TypeError [ERR_INVALID_URL]: Invalid URL: 
[2022-08-07 23:32:00.149] error: [strapi-plugin-sitemap]: Something went wrong while trying to build the SitemapStream. TypeError [ERR_INVALID_URL]: Invalid URL: 
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error
    at Object.createSitemap (/srv/app/node_modules/strapi-plugin-sitemap/server/services/core.js:248:11)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error
    at Object.createSitemap (/srv/app/node_modules/strapi-plugin-sitemap/server/services/core.js:248:11)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error
    at Object.createSitemap (/srv/app/node_modules/strapi-plugin-sitemap/server/services/core.js:248:11)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error
    at Object.createSitemap (/srv/app/node_modules/strapi-plugin-sitemap/server/services/core.js:248:11)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error
    at Object.createSitemap (/srv/app/node_modules/strapi-plugin-sitemap/server/services/core.js:248:11)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error
    at Object.createSitemap (/srv/app/node_modules/strapi-plugin-sitemap/server/services/core.js:248:11)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error
    at Object.createSitemap (/srv/app/node_modules/strapi-plugin-sitemap/server/services/core.js:248:11)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error
    at Object.createSitemap (/srv/app/node_modules/strapi-plugin-sitemap/server/services/core.js:248:11)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error
    at Object.createSitemap (/srv/app/node_modules/strapi-plugin-sitemap/server/services/core.js:248:11)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error
    at Object.createSitemap (/srv/app/node_modules/strapi-plugin-sitemap/server/services/core.js:248:11)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error
    at Object.createSitemap (/srv/app/node_modules/strapi-plugin-sitemap/server/services/core.js:248:11)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
(node:95) Warning: [deprecated] In future versions, Strapi will stop reading directly from the environment variable API_TOKEN_SALT. Please set apiToken.salt in config/admin.js instead.
For security reasons, keep storing the secret in an environment variable and use env() to read it in config/admin.js (ex: `apiToken: { salt: env('API_TOKEN_SALT') }`). See https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/configurations/optional/environment.html#configuration-using-environment-variables.
(Use `node --trace-warnings ...` to show where the warning was created)
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error
    at Object.createSitemap (/srv/app/node_modules/strapi-plugin-sitemap/server/services/core.js:248:11)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error
    at Object.createSitemap (/srv/app/node_modules/strapi-plugin-sitemap/server/services/core.js:248:11)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error
[2022-08-07 23:33:00.198] error: [strapi-plugin-sitemap]: Something went wrong while trying to build the SitemapStream. TypeError [ERR_INVALID_URL]: Invalid URL: 
[2022-08-07 23:34:00.188] error: [strapi-plugin-sitemap]: Something went wrong while trying to build the SitemapStream. TypeError [ERR_INVALID_URL]: Invalid URL: 
[2022-08-07 23:35:00.187] error: [strapi-plugin-sitemap]: Something went wrong while trying to build the SitemapStream. TypeError [ERR_INVALID_URL]: Invalid URL: 
[2022-08-07 23:36:00.152] error: [strapi-plugin-sitemap]: Something went wrong while trying to build the SitemapStream. TypeError [ERR_INVALID_URL]: Invalid URL: 
[2022-08-07 23:37:00.161] error: [strapi-plugin-sitemap]: Something went wrong while trying to build the SitemapStream. TypeError [ERR_INVALID_URL]: Invalid URL: 
[2022-08-07 23:38:00.151] error: [strapi-plugin-sitemap]: Something went wrong while trying to build the SitemapStream. TypeError [ERR_INVALID_URL]: Invalid URL: 
[2022-08-07 23:38:10.917] info: File created: /srv/app/docker-compose.yaml
Starting the compilation for TypeScript files in /srv/app
The server is restarting

[2022-08-07 23:39:23.680] info: --------  MIGRATION STARTED  --------
[2022-08-07 23:39:23.702] warn: No migration directory found.
[2022-08-07 23:39:23.703] info: --------  MIGRATION FINISHED  --------
[2022-08-07 23:39:23.741] info: [website builder] manual trigger enabled

 Project information

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Time               β”‚ Sun Aug 07 2022 23:39:24 GMT+0000 (Coordinated … β”‚
β”‚ Launched in        β”‚ 27742 ms                                         β”‚
β”‚ Environment        β”‚ development                                      β”‚
β”‚ Process PID        β”‚ 95                                               β”‚
β”‚ Version            β”‚ 4.3.2 (node v14.20.0)                            β”‚
β”‚ Edition            β”‚ Community                                        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

 Actions available

Welcome back!
To manage your project πŸš€, go to the administration panel at:
http://localhost:1337/admin

To access the server ⚑️, go to:
http://localhost:1337

[2022-08-07 23:40:00.154] error: [strapi-plugin-sitemap]: Something went wrong while trying to build the SitemapStream. TypeError [ERR_INVALID_URL]: Invalid URL: 
[2022-08-07 23:41:00.162] error: [strapi-plugin-sitemap]: Something went wrong while trying to build the SitemapStream. TypeError [ERR_INVALID_URL]: Invalid URL: 
[2022-08-07 23:42:00.163] error: [strapi-plugin-sitemap]: Something went wrong while trying to build the SitemapStream. TypeError [ERR_INVALID_URL]: Invalid URL: 
[2022-08-07 23:43:00.145] error: [strapi-plugin-sitemap]: Something went wrong while trying to build the SitemapStream. TypeError [ERR_INVALID_URL]: Invalid URL: 
[2022-08-07 23:44:00.157] error: [strapi-plugin-sitemap]: Something went wrong while trying to build the SitemapStream. TypeError [ERR_INVALID_URL]: Invalid URL: 
[2022-08-07 23:45:00.184] error: [strapi-plugin-sitemap]: Something went wrong while trying to build the SitemapStream. TypeError [ERR_INVALID_URL]: Invalid URL: 
[2022-08-07 23:46:00.220] error: [strapi-plugin-sitemap]: Something went wrong while trying to build the SitemapStream. TypeError [ERR_INVALID_URL]: Invalid URL: 
[2022-08-07 23:47:00.184] error: [strapi-plugin-sitemap]: Something went wrong while trying to build the SitemapStream. TypeError [ERR_INVALID_URL]: Invalid URL: 
[2022-08-07 23:48:00.174] error: [strapi-plugin-sitemap]: Something went wrong while trying to build the SitemapStream. TypeError [ERR_INVALID_URL]: Invalid URL: 
[2022-08-07 23:49:00.134] error: [strapi-plugin-sitemap]: Something went wrong while trying to build the SitemapStream. TypeError [ERR_INVALID_URL]: Invalid URL: 
[2022-08-07 23:50:00.162] error: [strapi-plugin-sitemap]: Something went wrong while trying to build the SitemapStream. TypeError [ERR_INVALID_URL]: Invalid URL: 
    at Object.createSitemap (/srv/app/node_modules/strapi-plugin-sitemap/server/services/core.js:248:11)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error
    at Object.createSitemap (/srv/app/node_modules/strapi-plugin-sitemap/server/services/core.js:248:11)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error
    at Object.createSitemap (/srv/app/node_modules/strapi-plugin-sitemap/server/services/core.js:248:11)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error
    at Object.createSitemap (/srv/app/node_modules/strapi-plugin-sitemap/server/services/core.js:248:11)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error
    at Object.createSitemap (/srv/app/node_modules/strapi-plugin-sitemap/server/services/core.js:248:11)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error
    at Object.createSitemap (/srv/app/node_modules/strapi-plugin-sitemap/server/services/core.js:248:11)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error
    at Object.createSitemap (/srv/app/node_modules/strapi-plugin-sitemap/server/services/core.js:248:11)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error
    at Object.createSitemap (/srv/app/node_modules/strapi-plugin-sitemap/server/services/core.js:248:11)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error
    at Object.createSitemap (/srv/app/node_modules/strapi-plugin-sitemap/server/services/core.js:248:11)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)

This altogether

Steps to reproduce the behavior

  1. Go Sitemap.
  2. Go to the container logs(either in terminal or docker desktop).
  3. Scroll down to find the error.
  4. See an error

Expected behavior

We should not get any error in both the docker logs and the website.

Screenshots

sitemaperror

System

  • Node.js version: 4.3.2 (node v14.20.0)
  • Strapi version: 4.3.2
  • Plugin version: 2.0.8
  • Database: PostgreSQL 13.7
  • Operating system: Alpine Linux v3.16

Additional context

Add any other context about the problem here.

not able to add more field types to the allowedFields in config/plugins.js

Bug report

Describe the bug

I am trying to add the 'text' field type to allowedFields, by adding 'text' to the allowed fields array in config/plugins.js. however the UI in Strapi does not update to make 'text' fields available in the dropdown.

Steps to reproduce the behavior

  1. Add the below code to config/plugins.js
    module.exports = ({ env }) => ({ sitemap: { enabled: true, config: { autoGenerate: true, allowedFields: ['id', 'uid', 'text'], excludedTypes: [], } } })
  2. Open Strapi dashboard
  3. Under 'Plugins', click 'Sitemap'
  4. Add or edit an existing collection that has a text field type
  5. Under UID Field, note that 'text' field types are not available

Expected behavior

After adding 'text' to the allowedFields array in the config/plugins.js file I would expect this field to be available in the UID Field dropdown in Strapi.

Code snippets

module.exports = ({ env }) => ({ sitemap: { enabled: true, config: { autoGenerate: true, allowedFields: ['id', 'uid', 'text'], excludedTypes: [], } } })

System

  • Node.js version: 12.21.0
  • NPM version: 6.14.11
  • Strapi version: 3.6.1
  • Plugin version: 1.2.5
  • Database: mysql 2.18.1
  • Operating system: MacOS Monterey

Surgical URL injection / Caching

Feature request

Summary

When you have the autoGenerate setting enabled and you update a piece of content, all the pages that should be included in the sitemap are queried and afterwards added to the sitemap. If you have a larger sitemap is could be a big performance issue.

Why is it needed?

It is probably best to only update the URL of the page you have just created, edited or deleted. So only that page will be queried. We can do this by implementing some kind of caching layer.

Suggested solution(s)

Solution 1:
Create a urls.json file in which you store al the URLs of the sitemap.
You could surgically add, edit or remove URLs from this file and afterwards regenerate the sitemap.xml based on that JSON file.

Solution 2:
Instead of having an extra JSON file that holds the URLs, we could (maby) also just read the URLs from the sitemap.xml file itself and use those to then again regenerate the sitemap.

Progress indicator for sitemap generations

Feature request

Summary

When you generate a large sitemap it can take some time. We should show some kind of progress indicator to show you the progress of building the sitemap XML.

Why is it needed?

Because otherwise the developer is waiting for a long time and doesn't know what's going on.

Suggested solution(s)

Some kind of progress indicator that shows you a percentage of how far the sitemap build is.

Related issue(s)/PR(s)

#83

Develop Branch compatibility

Hi, I'd like to leave you a question, is the development branch compatible with the Strapi v3.6.X?
I'm asking it because as I installed it, there were some dependencies that my project didn't have such as the @strapi/helper-plugin, and after installing these dependencies and building the project again, it didn't open, so, is this branch only available for versions >v4?

The `/sitemap/xsl/sitemap.xsl` file is Not Found when I try to reach my sitemap `http://localhost:1337/sitemap/index.xml`

Bug report

Describe the bug

The problem is when I try to reach my sitemap through this URL http://localhost:1337/sitemap/index.xml, I got nothing rendered in the browser, and when I check the chrome dev tool network I got this error

Request URL: http://localhost:1337/sitemap/xsl/sitemap.xsl
Request Method: GET
Status Code: 404 Not Found
Remote Address: 127.0.0.1:1337
Referrer Policy: no-referrer

Screenshots

Screenshot 2022-10-24 at 12 50 49

System

  • Node.js version: >=16.16.0 <=18.x.x
  • NPM version: >=6.0.0
  • Strapi version: 4.4.1
  • Plugin version: 2.0.8
  • Database:
  • Operating system: macOS

Additional context

Maybe this is related to the issue when I installed the plugin I had to create a sitemap manually inside the public folder, otherwise, I get an error

2022-10-24 13:25:54.947] error: [strapi-plugin-sitemap]: Something went wrong while trying to write the sitemap XML file to your public folder. Error: ENOENT: no such file or directory, open 'public/sitemap/index.xml'
Error

Allow query params

Right now it is not possible to create a sitemap entry with query params. The input field simply permits typing in a questionmark. e.g.:

  • some-overview?page=2
  • /?location=[id]

Is there any reason for this? Or any workaround?

Thank you!

Remove filter by `published_at` if `Exclude drafts: false` to properly works on collections with turned off Draft/Publish

Bug report

Describe the bug

A clear and concise description of what the bug is.

Steps to reproduce the behavior

  1. Create a collection with turned off Draft/Publish system on collection.
  2. Try to generate sitemap on that collection

Expected behavior

Sitemap is generated

Actual behavior

Error in console
image

System

  • Strapi version: 4.1.0
  • Plugin version: 2.0.6
  • Database: Postgres

Additional context

If remove filter by published_at in core services - works fine. So suggested solution is to check for Exclude drafts config set to false and then not filter by published_at

Throws error when i18n plugin is not installed

Bug report

Describe the bug

If I don't have the i18n plugin installed, the sitemap plugin throws the following error when I access the plugin page in the admin panel:

error: Model plugin::i18n.locale not found

Steps to reproduce the behavior

  1. Setup a strapi instance without i18n plugin installed
  2. Navigate to the sitemap settings
  3. See error banner pop up and notice error in console output.

Expected behavior

No error is thrown, missing i18n plugin is ignored.

Even better would be, if the plugin just hid all the i18n-related settings. Just a nice to have.

System

(Shouldn't matter)

  • Node.js version: v14.18.2
  • NPM version: 6.14.15
  • Strapi version: 4.0.0
  • Plugin version: 2.0.0
  • Database: sqlite
  • Operating system: Linux

Allow Configuration for Read/Write Directory

Hello πŸ‘‹

I'm wondering whether it would be possible to make the write/read directories configurable rather than hard-coded?

We are building for a AWS Lambda deployment and can only write the to /tmp directory.

With serverless becoming more and more common, maybe others would benefit from this as well?

Feature request: an ability to use the same collection with different patterns

Feature request

Summary

Can you add an ability to specify a few patterns for the same collection?

For example I have collection products and I want to have a few patterns for it. For example:

/products/[id]
/products/[id]/another-slug-1
/products/[id]/another-slug-2

Why is it needed?

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Suggested solution(s)

There are 2 options for that:

  • If it possible to extend this dialog to have a few patterns (and have priority and changefreq for each pattern)

Screenshot 2022-01-11 at 20 23 38

- Allow to use the same collection a few times for URL bundles (I think this is more preferable way)

Feature Request: Cloud-based sitemap storage

Hello,

Feature request

Thanks for you great work on this beautiful plugin.

For now plugin don't very support cloud-based deployments, and it's will be nice to have it, main problems:

  • if we have multiple instance of strapi launched, there is no way to restrict only one of them to generate sitemap's (e.g. dedicated sitemap generator worker), it can be solved by some CLI command for generate sitemaps
  • would be nice to have automatic sitemap upload to some cloud storages (and way to configure it over config), e.g. gcs or s3
  • there is no way to set sitemap hostname in config (and would be nice to have way to override any settings in config), and deny to change it in admin panel by users

Unexpected token '.' error when deploying to GCP App Engine

Bug report

Describe the bug

Hi there,
After I set up the sitemap plugin, I cannot deploy the code to the Google Cloud Platform App Engine.
This is the error I'm having.

> strapi start
[2021-12-21 01:52:20.738] debug: \u26d4\ufe0f Server wasn't able to start properly.
[2021-12-21 01:52:20.742] error: Could not load js config file /app/node_modules/strapi-plugin-sitemap/strapi-server.js: Unexpected token '.'
Error: Could not load js config file /app/node_modules/strapi-plugin-sitemap/strapi-server.js: Unexpected token '.'
    at loadJsFile (/app/node_modules/@strapi/strapi/lib/core/app-configuration/load-config-file.js:18:11)
    at loadFile (/app/node_modules/@strapi/strapi/lib/core/app-configuration/load-config-file.js:35:14)
    at Object.loadPlugins (/app/node_modules/@strapi/strapi/lib/core/loaders/plugins/index.js:109:26)
    at async Strapi.loadPlugins (/app/node_modules/@strapi/strapi/lib/Strapi.js:279:5)
    at async Promise.all (index 1)
    at async Strapi.register (/app/node_modules/@strapi/strapi/lib/Strapi.js:311:5)
    at async Strapi.load (/app/node_modules/@strapi/strapi/lib/Strapi.js:409:5)
    at async Strapi.start (/app/node_modules/@strapi/strapi/lib/Strapi.js:161:9)

Any Idea?

System

  • Node.js version: v14.17.2
  • NPM version: 6.14.13
  • Strapi version: 4.0.0
  • Plugin version: 2.0.2
  • Database: Postgres 13
  • Operating system: Linux

Relational URL pattern

Feature request

Summary

Allow querying relational fields in the URL pattern like /prefix/[relation.slug_field].

Why is it needed?

For better dynamic URL patterns.

Related issue(s)/PR(s)

#75

Error: Cannot read property 'attributes' of undefined

I am receiving Cannot read property 'attributes' of undefined when I click "Add" or "edit"
image

Both of collections have UID field. I'm also new to strapi so I might do something wrong. Using latest version.

EDIT: Also reciving error when deleting all and pressing "add 1 by 1"
image

Some sc of error:
image
image

Feature request: an ability to exclude last modification date from generated sitemap

Feature request

Summary

Can you and a new option to URL bundles to exclude last modification date for collections.

Why is it needed?

We have a pages on website that receive part of data from Strapi CMS and another part from our own API. In our case last modification date in Strapi CMS is incorrect because our API updates data more frequently and we want to exclude last modification date from sitemap for this pages.

Unable to generate sitemap when collection names have a space

I am currently unable to generate the sitemap if my collection name has a space (We have done this for it to be human readable on the CMS itsself, annoyingly strapi does not allow for seperate display and data names..)

This is an example of a collection model that does not work:

{ "kind": "collectionType", "connection": "default", "collectionName": "help_article", "info": { "name": "Help Article" }, "options": { "increments": true, "timestamps": true }, "attributes": { "Url slug": { "type": "string" }, "Article title": { "type": "string" }, "Image": { "model": "file", "via": "related", "plugin": "upload" }, "Sub title": { "type": "string" }, "Blurb": { "type": "string" }, "Content": { "type": "richtext" }, "Page title (head tag)": { "type": "string" }, "Page description (head tag)": { "type": "string" } } }

We believe it blows up on this line

Thanks for any help on this!

Strapi Build fails having this plugin for @strapi/strapi v.4.5.5

Strapi Build fails having this plugin for @strapi/strapi v.4.5.5

Description

With the strapi version v.4.5.5 , after updating core strapi packages. Trying to build the strapi project dosn't work.

Steps to reproduce the behavior

  1. Upgrade all of the Strapi packages version numbers in package.json to the latest stable Strapi version:
{
  "dependencies": {
    "@notum-cz/strapi-plugin-content-versioning": "^0.4.7",
    "@palmabit/strapi-app-version": "^1.1.0",
    "@strapi/plugin-graphql": "^4.5.5",
    "@strapi/plugin-i18n": "^4.5.5",
    "@strapi/plugin-seo": "^1.7.7",
    "@strapi/plugin-users-permissions": "^4.5.5",
    "@strapi/strapi": "^4.5.5",
    "better-sqlite3": "^8.0.1",
    "strapi-plugin-comments": "^2.2.1",
    "strapi-plugin-duplicate-button": "^1.0.4",
    "strapi-plugin-preview-button": "^1.0.1",
    "strapi-plugin-publisher": "^1.1.4",
    "strapi-plugin-sitemap": "^2.0.8",
    "strapi-plugin-slugify": "^2.3.2"
  }
}
  1. Execute the build command npm run build

Expected behavior

Plugin should be working fine after updating

Output Error

ModuleNotFoundError: Module not found: Error: Can't resolve '@fortawesome/react-fontawesome' in '/home/woozi/work/admire/2022/karthikaspices/website/backend-karthika/node_modules/strapi-plugin-sitemap/admin/src/components/PluginIcon'

System

  • Node.js version: v14.21.2
  • NPM version: 6.14.17
  • Strapi version: "@strapi/strapi": "^4.5.5"
  • Plugin version: "strapi-plugin-sitemap": "^2.0.8"
  • Database: "better-sqlite3": "^8.0.1"
  • Operating system: Ubuntu 22.04.1 LTS x86_64

GCP / GAE Deployment: No wirteable filesystem

Feature request

Summary

Deploying a strapi-plugin-sitemap project to Google App Engine does not work.
Did anyone got this plugin to work on a GAE?
From my understanding the GAE filesystem is read only. For writing files Google Cloud Storage is recommended. Therefore the plugin can not create nor write to files in the /public/sitemap folder.

Why is it needed?

plugin shall work on GAE

Suggested solution(s)

Provide a setting to change the path of the generated sitemap.
In case of GAE it might be enough to change the path to /tmp/sitemap or to a Google Cloud Link.

Related issue(s)/PR(s)

Let us know if this is related to any issue/pull request.

JSON output support

Feature request

Summary

Hello, thank you for an amazing plugin. I have a question - is there any way to get JSON output without XML?

Why is it needed?

Because the frontend side has a different domain name and few frontend-specific routes, such as /terms, privacy, sign in, etc

Suggested solution(s)

JSON output with pagination support for split-sitemaps

Default locale

Bug report

First of all, this plugin is amazing. Thank you for working on this!

Describe the bug

The current behavior is kind of random - the content type sometimes appears in a locale as default and other times with another. That affects how the pages are ranked.

Steps to reproduce the behavior

  1. Install the plugin
  2. Add multiple contents with multiple locales
  3. Open the sitemap and see the default URL is not always in the same locale

Expected behavior

The content using the default locale should always be used as the default URL.

Screenshots

Notice that the default URL for the https://croct.com/blog/pt-br/post/perfil-progressivo appears as pt-br while for https://croct.com/blog/post/ultimate-guide-ab-testing-analysis is en-us (the correct is en-us, as it's the default locale).

image

System

image

Go to the Sitemap navigates to Localhost instead domain server

Bug report

Describe the bug

The Go to the Sitemap navigate to http://localhost:4000/sitemap/index.xml instead of the live domain

Steps to reproduce the behavior

  1. Go to 'Strapi Admin'
  2. Click on 'Sitemap'
  3. Click on 'Go to the Sitemap'
  4. New Window is opened
  5. Page navigates to http://localhost:4000/sitemap/index.xml

Expected behaviour

The page should be navigated to https://admin.cgafrica.com/sitemap/index.xml

Screenshots

If applicable, add screenshots to help explain your problem.

Code snippets

If applicable, add code samples to help explain your problem.

System

  • Node.js version:
  • NPM version: 6.0.0
  • Strapi version: 4.03
  • Plugin version:2.0.4
  • Database: sql
  • Operating system:

Additional context

Add any other context about the problem here.

Use of non UID type field

This plugin has been written to use UID type fields as URLs to build the sitemap xml.
Potentially we could use a non UID field as (part of the) URL, to use the ID field for example.

This is kind of an interest check. If this is something you would like to see, let me know in this issue.
If this is highly requested I will update the plugin.

404 when trying to access the settings

Hello,
First time I'm using the plugin and I'm struggling with it.
I have a 404 when I try to go to the plugin settings

Capture d’écran 2021-11-20 aΜ€ 11 16 51

I'm using an old version of strapi : "strapi": "3.0.0-beta.20",
Not sure it's supported ?

Also not sure how to generate the site map once you added settings. I used postman and the routes to populate my settings (not sure it's correct, and the hostname is not populating).
Capture d’écran 2021-11-20 aΜ€ 11 29 18
Capture d’écran 2021-11-20 aΜ€ 11 29 26

Thanks in advance,
Marie

Error "Javascript heap out of memory"

Bug report

Describe the bug

can't see any notification of sitemap is generating when pressing the button there is no info that how much time it will take or its generating the sitemap

Steps to reproduce the behavior

  1. Go to 'sitemap plugin'
  2. add URL bundle and save
  3. and generate sitemap
  4. you will see no notification is there that sitemap is generating

Expected behavior

It should show that sitemap is generating

System

  • Node.js version: V14.17
  • NPM version: 8.5
  • Strapi version: 4.1.7
  • Plugin version:2.0.7
  • Database:postgress
  • Operating system: ubuntu

Area/Path for collections can not be set individual

Each time i am changing the area/path for a collection type it's going to be changed for every other collection also which means i can not set individual areas/paths.
Tried already reinstalling the plugin but it seems like the "config file" isn't removed that way.

add trailing slash

hi, I want to add a trailing slash at the end of my routes.
how can I do that? thanks.

Unable to add to allowedFields


Edit: I have figured out most of it. I was overlooking that we add the data TYPE to allowed fields, instead of the field names. So now I have the fields available in the settings UI.

The only issue that I am seeing now is there is a many -to-one relation field that (this content type is the "one" part of the relation). The value is not showing in the sitemap, even though everything appears fine in the UI.

Edit 2: After digging through the source code, it appears that relation fields aren't supported. Closing this issue.


I am trying to use this plugin to generate a sitemap and am having an issue when trying to add some fields in the allowedFields section of config.

In config/plugins.js, I have added the following:

module.exports = {
    sitemap: {
      enabled: true,
      config: {
        autoGenerate: true,
        allowedFields: ['id', 'title']
      }
    }
}

Then when I attempt to add a new url bundle using the sitemap settings, I get the following error:

image

The only field that seems to work is "id". I don't know what I am missing here.

Any guidance would be appreciated.

Node version 16.13.0
Strapi plugin sitemap: 2.0.6
Strapi: 4.0.7
NPM : 8.1.3
OS: Windows 11
DB: sqlite

Support URLs containing slashes

Currently the plugin assumes that all Strapi pages are at the root of the site. URLs like https://my-site.com/articles/my-strapi-article-1 are not supported because the UID field used in the sitemap doesn't allow slashes. Custom entries have the same problem. I had a go at a solution here that adds an area property to the settings for both custom and collection entries. Let me know what you think.

image

Pattern: relations array

Feature request

Summary

As of #75 you can add relation fields to the URL pattern like so:

/test/[relation.field]/[id]

Though this only works for single relations. If the relation would be of target *ToMany we wouldn't know which entity to query exactly.

Suggested solution(s)

We should allow the pattern to be written like this to select a specific item of an array of relations.

/test/[relation[1].field]/[id]

Here we would select the second entity on the relations array.

[Question] Single collection type

Hey, I use version 2.0.8 of this package and I wonder if there is a way to add a single collection type under URL bundles? For example, right know I can't add something like "about", which is a single page/single collection type, with the URL /about.

The only solution seems to add it under "custom URLs" or am I missing something?

Plugin Admin Page breaks after sitemap.xml is generated

Bug report

Describe the bug

After generating sitemap, plugin admin page breaks and shows white page.

When I build strapi, it is built as production thus I could not resolve where the error originated from.

Steps to reproduce the behavior

  1. install strapi-plugin-sitemap: 2.0.9
  2. build strapi
  3. run strapi develop
  4. generate sitemap using plugin (any content) with pre generated contents.

Expected behavior

Plugin admin page(/admin/plugins/sitemap) shows that current xml is loaded.

Screenshots

Code snippets

System

  • Node.js version: node 16.17.1
  • NPM version: 8.15.0
  • Strapi version: 4.5.2
  • Plugin version: 2.0.9
  • Database: PostgreSQL
  • Operating system: MacOS Ventura (13.1)

Additional context

Important note : after downgrading this plugin to 2.0.8, things work properly.

probably these changes are inducing the error. (2.0.8 vs 2.0.9)

2.0.8...2.0.9

Generate double loc item & miss some of the links in sitemap

Bug report

Describe the bug

I found that there is some links missed and double generate links in sitemap. Links are generated by URL Bundles

a

Settings

URL Bundles
2

In config/plugins.js

module.exports = ({ env }) => ({
  'sitemap': {
    enabled: true,
    config: {
      autoGenerate: true,
      allowedFields: ['id', 'uid', 'slug'],
      excludedTypes: [],
    },
  },
  publisher: {
    enabled: true,
  },
});

Expected behavior

No duplicated loc items and all item in URL Bundles should be generated

System

  • Node.js version: 14
  • Strapi version: 4.0.7
  • Plugin version: 2.0.6
  • Database: Postgresql 13
  • Operating system:

Does not work with Container hosted instances

@boazpoolman awesome job, really great plugin. I'm running into a problem with hosting it in a container though. Most of the plugins for strapi get added to either /api or /extensions, but this one doesn't. I suspect that it is saving everything under the local node_modules folder? This then becomes an issue when packaged since the routes added to save configs don't get packaged, so you can't update once in the container.

Looking for thoughts on how to get around this. Once I figure that out, I'll be happy to help you add it to the package permanently.

URL Bundles not generating for pre-existing collections.

Bug report

URL Bundles not generating for pre-existing collections.

On adding a URL bundle for a pre-existing collection that existed before plugin installation, links are not generated. Links are only generated for new entries made after installation. Duplicating pre-existing content does not generate a link either.

Steps to reproduce the behavior

  1. Create Strapi instance
  2. Create content collections (possibly without a UID field since I didn't have one before making URL bundles)
  3. Populate and publish the content collection
  4. Install sitemap plugin
  5. Create url bundle for the content collection
  6. Save and generate sitemap
  7. See error

Expected behavior

URL's created for the content collection.

System

  • Node.js version: 14.18.2
  • NPM version: 8.3.0
  • Strapi version: 4.0.4
  • Plugin version: 2.0.4

Additional context

Some of the other collections weren't generating either.
For one, I could get them generated by editing and saving content.
For another, I had to duplicate the content and delete the old one.
Neither of these worked for the ones created before adding the plugin.

Feature Request: Add support for sitemapindex

Feature request

Summary

Please add support for the sitemapindex.

Why is it needed?

We generally split our sitemaps using a global sitemap index, which loads the site's sub-sitemaps.

This makes it easier to request a re-indexing from search engines, and allows to combine the sitemap of a global site from different sub-site.

Suggested solution(s)

For instance, instead of the existing custom URLs, a separate front-end could generate its own routes-based sitemap, and in Strapi we could request the inclusion of this specific sitemap.

Related issue(s)/PR(s)

N/A

Plugin configuration not available in Strapi 3.1.1 and 3.1.2

Version

Strapi 3.1.1 & 3.1.2

Steps to reproduce

  • Install plugin, delete build and .cache folders and run yarn build --clean
  • Clean browser cache

What is Expected?

The plugin should be listed in the Admin Dashboard

What is actually happening?

It's not showing so you cannot configure the plugin

Screenshot 2020-07-30 at 21 15 00

Screenshot 2020-07-30 at 21 15 17

Using no prefix (`/[slug]`) resolve to broken url

Bug report

Describe the bug

When we use a pattern like /[uri] which can contain /, the resolved url does not contain the hostname

Steps to reproduce the behavior

  1. Go to http://127.0.0.1:1337/admin/plugins/sitemap
  2. Add a URL Bundle with a pattern like /[uri]
  3. Set a hostname in settings like http://localhost:3000/ (or http://localhost:3000)
  4. Save
  5. Create an entity with /foo/bar as uri
  6. Generate sitemap

Expected behavior

The url should contain the hostname

Screenshots

image

Additional context

Adding any string in the pattern before the brackets like /foo/[slug] or /foo/bar/[id] works

Multilingual support

With the release of Strapi 3.6.0 we are now able to translate our pages.
Multiple languages means multiple URLs.
We should implement this throughout the sitemap based on Google's guidelines: Multilingual sitemaps

Clearer explanation of the Allowed fields

Feature request

Summary

A clearer explanation of the Allowed fields in the Readme to explain that it is the type of the fields and not the field names

Why is it needed?

At first I thought that this field was an array of the fields names instead of being their types, so I filled with the names that I wanted for the sitemap to be generated with.
When it didn't work, I searched through the source code to understand why it doesn't work and found it that this array was instead a list of types to be included.

Suggested solution(s)

Make it clearer that it is a list of types. I know that it is said that way in the Readme, but it is not very clear what it is.
Maybe include an example of an array that is not only ["id", "uid"], but also something like ["id", "string"].

Sorry if this feels a bit much, but I was almost being discouraged of using this plugin as I thought that there was a bug inside.

Related issue(s)/PR(s)

Plugin settings section not visible in Strapi v4.1.12

Bug report

Description

Can't find/see the plugin settings in the admin panel after installation of the plugin, rebuilding en restarting. The plugin seems to be added and present in the plugins overview.

Steps to reproduce the behavior

  1. In the root of the Strapi folder install with npm npm install strapi-plugin-sitemap --save
  2. Rebuild and restart Strapi in develop mode
  3. Check the plugins section, which shows the Sitemap is present
  4. Can't find the settings page for this plugin

Expected behavior

Find the settings section of this plugin in the Settings page of Strapi

Screenshots

Screenshot 2022-06-17 at 10 34 48

Screenshot 2022-06-17 at 10 34 17

System

  • Node.js version: 14.15.0
  • NPM version: 8.12.1
  • Strapi version: 4.1.12
  • Plugin version: 2.0.8
  • Database: Postgress
  • Operating system: MacOSX with Firefox browser

CLI to generate sitemap from the command line

Feature request

Summary

Have a strapi-sitemap CLI with a generate command so you can generate the sitemap XML from the CLI.

Why is it needed?

This is useful when using a loadbalancer with multiple Strapi instances.
Generating sitemap in each instance separately can cause problems (performance and race-conditions).

So when having a CLI you can disable auto generation and have a special worker dedicated to generating the sitemap.

Related issue(s)/PR(s)

#84

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.