pecotamic / sitemap

Sitemap for Statamic v3
6 stars 9 forks source link

FR: Can we have the ability to omit certain pages from the site map #1

Closed Blucreation closed 3 years ago

Blucreation commented 3 years ago

A simple array for omission of certain pages in config/pecotamic/sitemap.php would suffice

prageeth commented 3 years ago

I too needed this functionality, so I have opened this PR. I have tested it with one of my own sites and it works well. https://github.com/pecotamic/sitemap/pull/2

prageeth commented 3 years ago

@Blucreation You can use my repo as a temporary fix until my PR is merged here:

Remove the original addon:

composer remove pecotamic/sitemap

Add this to your composer.json file

{
  ...
  "require": {
      ...
      "pureartisan/sitemap": "dev-master"
      ...
  },
  "repositories": [
      {
        "type": "vcs",
        "url": "https://github.com/pureartisan/sitemap.git"
      }
  ]
}

Install:

composer install

Update the config (same config file as before config\pecotamic\sitemap.php):

return [
    'url' => 'sitemap.xml',
    'expire' => 60,
    'include_entries' => true,
    'include_terms' => true,
    'include_collection_terms' => true,
    /**
     * - Leave as `null` for all types
     * - Provide array of types/handles for filtering
     */
    'entry_types' => [ 'pages', 'foo' ], // only include pages and foo
    /**
     * - Use valid regex patterns (uses `preg_match`)
     * - Relative URLs (relative to site url)
     */
    'exclude_urls' => [
         '#^\/my-path\/.*#' // exclude all `/my-path/*`
    ]
];
werner-freytag commented 3 years ago

Release 1.2.0 adds the changes by @prageeth