Giter Club home page Giter Club logo

sitemap-plugin's Introduction

RainLab Sitemap is no longer under active development

Please note that the RainLab Sitemap plugin is no longer under active development. It has been superseded by a new form widget called Page Finder, which offers flexible support for defining sitemaps, including multisite support.

Sitemap generator plugin

This plugin will a generate sitemap.xml file in October CMS based on desired CMS pages and others.

Viewing the sitemap

Once this plugin is installed and the sitemap has been configured. The sitemap can be viewed by accessing the file relative to the website base path. For example, if the website is hosted at https://octobercms.com it can be viewed by opening this URL:

https://octobercms.com/sitemap.xml

Managing a sitemap definition

The sitemap is managed by selecting Sitemap from the Settings area of the back-end. There is a single sitemap definition for each theme and it will be created automatically.

A sitemap definition can contain multiple items and each item has a number of properties. There are common properties for all item types, and some properties depend on the item type. The common item properties are Priority and Change frequency. The Priority defines the priority of this item relative to other items in the sitemap. The Change frequency defines how frequently the page is likely to change.

Standard item types

The available item types depend on the installed plugins, but there are three basic item types that are supported out of the box.

URL {.subheader}

Items of this type are links to a specific fixed URL. That could be an URL of an or internal page. Items of this type don't have any other properties - just the title and URL.

Static page {.subheader}

Items of this type refer to static pages. The static page should be selected in the Reference drop-down list described below.

All static pages {.subheader}

Items of this type expand to create links to all static pages defined in the theme.

Custom item types

Other plugins can supply new item types. For example, the Blog plugin by RainLab supplies two more types:

Blog category {.subheader}

An item of this type represents a link to a specific blog category. The category should be selected in the Reference drop-down. This type also requires selecting a CMS page that outputs a blog category.

All blog categories {.subheader}

An item of this time expands into multiple items representing all blog existing categories. This type also requires selecting a CMS page.

Definition item properties

Depending on the selected item time you might need to provide other properties of the item. The available properties are described below.

Reference {.subheader}

A drop-down list of objects the item should refer to. The list content depends on the item type. For the Static page item type the list displays all static pages defined in the system. For the Blog category item type the list displays a list of blog categories.

Allow nested items {.subheader}

This checkbox is available only for item types that suppose nested objects. For example, static pages are hierarchical, and this property is available for the Static page item type. On the other hand, blog categories are not hierarchical, and the checkbox is hidden.

CMS Page {.subheader}

This drop-down is available for item types that require a special CMS page to refer to. For example, the Blog category item type requires a CMS page that hosts the blogPosts component. The CMS Page drop-down for this item type will only display pages that include this component.


The Sitemap plugin works out of the box and does not require any direct development to operate.

Registering new sitemap definition item types

The Sitemap plugin shares the same events for registering item types as the Pages plugin. See the documentation provided by this plugin for more information.

A small addition is required when resolving items, via the following event:

  • pages.menuitem.resolveItem event handler "resolves" a menu item information and returns the actual item URL, title, an indicator whether the item is currently active, and subitems, if any.
Resolving items

When resolving an item, each item should return an extra key in the array called mtime. This should be a Date object (see Carbon\Carbon) or a timestamp value compatible with PHP's date() function and represent the last time the link was modified.

Expected result format:

Array (
    [url] => https://example.com/blog/category/another-category
    [mtime] => Carbon::now(),
    [items] => Array (
        [0] => Array (
            [url] => https://example.com/blog/category/another-category
            [mtime] => Carbon::now(),
        )

        [1] => Array (
            [url] => https://example.com/blog/category/news
            [mtime] => Carbon::now(),
        )
    )
)

sitemap-plugin's People

Contributors

acasar avatar anik1ng avatar blazorazem avatar daftspunk avatar diraulo avatar emzet avatar gergo85 avatar jh2odo avatar lemax10 avatar luketowers avatar magiczne avatar mahony0 avatar matissjanis avatar mjauvin avatar mohsin avatar mr118 avatar octoberapp avatar raank avatar ribsousa avatar samgeorges avatar samuell1 avatar theservat avatar vojtasvoboda avatar zek avatar zhiweiwu0425 avatar

Stargazers

 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  avatar  avatar  avatar  avatar

sitemap-plugin's Issues

Show dynamic parameters for pages where are used models made in Builder plugin

Hi there, I have problem showing dynamic parameters in url's for pages that are using models made in Builder plugin.
Example page :

url = "/product/:slug"
layout = "default"
title = "Product"
==
<?php
use Codeupp\Client\Models\Product;
function onStart(){
$slug = $this->param('slug');
$product = Product::where('slug', $slug)->first();
if(!$product){
return Redirect::to('/');
}
$this['product'] = $product;
}
?>
==

and sitemap object for this url looks like this:

<url>
<loc>https://client.com/product/default</loc>
<lastmod>2023-06-09T14:07:43+00:00</lastmod>
<changefreq>monthly</changefreq>
<priority>0.6</priority>
</url>

Is there a way for me to make this work somehow, or is my approach wrong here? Thanks.

No sitemap definition was found

OctoberCMS Build: ### 3.1.21
RainLab Sitemap-Plugin Version: ### 1.2.3
PHP Version: 8.1.4

EventLog
No sitemap definition was found. Try creating one first.

Disabled plugin still renders /sitemap.xml

If you disable this plugin, it doesn't remove the URL from the known routes in the CMS.

October: 430
Sitemap: 1.0.8

Expected behavior:
Disabling sitemap in settings, should throw 404 when going to /sitemap.xml.

Actual behavior:
Disabling sitemap in settings, still shows the sitemap when going to /sitemap.xml

The sitemap shows disabled pages

Hi, thanks for this plugin.
I used it to generate my sitemap, but it lists also the items that are disabled. I'd prefer that it is not displayed to search engines.

To reproduce :

  • Create a tailor collection
  • Add several items
  • Publish some, leave others disabled (is_enabled = false)
  • Create a page to display the item with the url scheme "my-collection/:slug"
  • Create the sitemap entry to list All these entries

I tried to add a condition in the macro, but the Page finder item doesn't return the proper tailor item.
It returns the same strange item for all entries, with a slug equivalent to "my-collection", not the real slug, not the true item data, and not the correct is_enabled value.

I don't know how to go further. Can you help ?

cms page - no matches found

Hello,
I tried out the plugin and I would like to add an item related to all blog categories. I have a cms page that shows all blog entries from rainlab - blog. But this page is not in the CMS Page dropdown. Are there some configuration I missed?

Thanks
Rob

[ERROR] Site Definition Error

Hello,

I noticed the following error on OctoberCMS v3.4.9 (with enabled MultiSites), while viewing the generated sitemap.xml.

[2023-07-22 13:00:51] prod.ERROR: ErrorException: Undefined property: RainLab\Sitemap\Classes\DefinitionItem::$sites in /modules/cms/classes/Page.php:213

Simple fixed it by adding public $sites; on the shown sitemap/classes/DefinitionItem.php file.

Sincerely,
Sam.

Restrict User Access

It could be really nice if you can add permissions.

Any user can access it in backend.

Is it possible to use custom post types (automatically) in the sitemap plugin?

The sitemap plugin supports the Blog- and Forum plugin out of the box. I was wondering if it's at all possible to extend this functionality to custom plugins.

My plugin consists of a list of items, each one having their own url. It would be nice if I could get my items into the sitemap without having to define them manually per item (because items will be added / renamed / removed).

The documentation seems to stay a little vague about this. Is this possible and if so, is there a working example available somewhere?

Thanks in advance.

Error while accessing sitemap.xml

Hello,

We have the sitemap plugin installed for a few years now in our website. But recently it started behaving weirdly. The error shown in the below screenshot appears very regularly.
sitemap-error

Once we open the sitemap menu/link from the settings section, we will be able to see the sitemap.xml file correctly. But after some 3 to 4 hours of time again it will display the same error as shown in the first screenshot.

After accessing the sitemap page from the settings section. It will revert back to normal.
image

image

Easier way to implement custom itemTypes

I find it very tedious to implement the logic for generating custom itemTypes like blog-post and all-blog-posts. I keep copying the logic again and again for each project/plugin.

I'm looking at ways to make this proces easier/less tedious. It might be an idea to add custom behaviours to this plugin, so we only need to define the parameters necessary to output custom post types.

My suggested approach:

  • Use a behavior to define the standard functions like resolveMenuItem etc
  • User has to add fields to the model for the needed input that varies for each itemType.
$itemType = 'blog-post';
$componentName = 'blogPost';
$scope = `isVisible`;

Hurdles I can think of:

  • Combining singular and multiple item logic (blog-post vs all-blog-posts)
  • Combining multiple itemtypes in 1 model (blog-post / category etc)

Does anyone have any input into this matter?

Implement urls with the language tag

Google recommends using different URLs for each language version of a page rather than using cookies or browser settings to adjust the content language on the page.

It will be possible to implement urls with the language tag?

Regards

SitemapHandler::sitemap() should not be called statically

Error after update from Sitemap plugin 1.2.0 to 1.2.2:

ErrorException: Non-static method RainLab\Sitemap\Handlers\SitemapHandler::sitemap() should not be called statically in /vendor/laravel/framework/src/Illuminate/Routing/Route.php:197

OC version 476.

sitemap.xml is empty?

I added some data for sitemap. but the sitemap content is empty of http://domain/sitemap.xml

That page content displayed without I added data, like this:

<?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"/>

How can I fix this problem?

URL rendering default instead of category in path

I'm having a problem when I try to use the blog category posts option, in that all the posts are being rendered with /default/ instead of the category.

I'm not sure if this is a bug with the sitemap plugin or something to do with the setup we have - the URL's all render fine on the front-end in the blog itself, and when I use blog category it has the correct URL as well.

Any ideas?

Reordering feature not working properly

Hi, I've been experiencing issues when trying to reorder items.
The problem occurs only if the list is bigger than the page (and the scrolling bar appears). For example if the page can show 10 list elements, there are problems reordering all the elements from the 11th.
It looks like the plugin doesn't take into account the scroll position of the list.

Thanks in advance

Hidden static pages

When use "All static pages" type
If static page is Hidden in navigation, than it and all childs will not appear in sitemap.
If static page is Hidden and not Hidden in navigation, than it will appear in sitemap.

I think only Hidden parameter should affect visibility of static pages in sitemap, and it should not affect childs.

XML declaration allowed only at the start of the document

There is an immediate line break at the start of the rendered XML file which causes an error on line 2 at column 6: XML declaration allowed only at the start of the document.

This behaviour is in our production environment but not in development with apparently same config and both on the latest version of the plugin. Have tried looking at plugin code and can't see why this is happening or how to fix it.

The rest of the sitemap.xml file is correct but not being read as failing before rendering any of the page up to the first error.

Seeing output I don't believe should render at the top of the output xml file

The text output that shows in the top of the sitemap is:
// Catch errors if signal is already set by user agent or other extension try { Object.defineProperty(navigator, 'globalPrivacyControl', { value: false, enumerable: true }) // Remove script tag after execution document.currentScript.parentElement.removeChild(document.currentScript) } catch (e) {}

Doesn't work with last build

It seems that Save on Sitemap doesn't work with last build 293. I tried to uninstall & install fresh and also tried Force Update. Error:

snimek obrazovky 2015-09-08 v 11 11 56

Call stack:

exception 'Exception' with message 'Unexpected type of array, should attribute "items" be jsonable?' in /www/vendor/october/rain/src/Database/Model.php:1110
Stack trace:
#0 /www/vendor/october/rain/src/Database/Model.php(1151): October\Rain\Database\Model->saveInternal(Array)
#1 /www/modules/backend/behaviors/FormController.php(261): October\Rain\Database\Model->save(NULL, 'YXAiDGNoZtoeLOu...')
#2 [internal function]: Backend\Behaviors\FormController->update_onSave('1')
#3 /www/vendor/october/rain/src/Extension/ExtendableTrait.php(311): call_user_func_array(Array, Array)
#4 /www/vendor/october/rain/src/Extension/Extendable.php(44): October\Rain\Extension\Extendable->extendableCall('update_onSave', Array)
#5 [internal function]: October\Rain\Extension\Extendable->__call('update_onSave', Array)
#6 [internal function]: RainLab\Sitemap\Controllers\Definitions->update_onSave('1')
#7 /www/modules/backend/classes/Controller.php(527): call_user_func_array(Array, Array)
#8 /www/modules/backend/classes/Controller.php(423): Backend\Classes\Controller->runAjaxHandler('onSave')
#9 /www/modules/backend/classes/Controller.php(233): Backend\Classes\Controller->execAjaxHandlers()
#10 /www/modules/backend/classes/BackendController.php(95): Backend\Classes\Controller->run('update', Array)
#11 [internal function]: Backend\Classes\BackendController->run('rainlab/sitemap...')

Software updating problem, database (MariaDB) doesn't want to update

Trying to update from 1.0.1 to 1.0.9.

image

And here's the bug showing after a few seconds.
Update failed
SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'rainlab_sitemap_definitions' already exists (SQL: create table rainlab_sitemap_definitions (id int unsigned not null auto_increment primary key, theme varchar(65535) null, data mediumtext null, created_at timestamp null, updated_at timestamp null) default character set utf8mb4 collate utf8mb4_unicode_ci engine = InnoDB)

Trying again doesn't help at all, same error shows up. Tried also to remove the table, and this showed up:
Update failed
SQLSTATE[42000]: Syntax error or access violation: 1170 BLOB/TEXT column 'theme' used in key specification without a key length (SQL: alter table rainlab_sitemap_definitions add index rainlab_sitemap_definitions_theme_index(theme))

Does not work with properly with translated URLs

Just wanted to let you know that translated URLs are not shown properly.
Based on the language selection it shows either the standard language or the translated language URLs but not both of them.

It doesn't open sitemap.xml

Screenshot_1
When trying to open sitemap.xml in which I added 3 cms pages, this error comes out through the plugin. How can I fix it?

Sitemap won't open, instead downloads source file

Hi,

I might be overlooking something, but in my setup (over multiple sites) when I navigate to https://domain.com/sitemap.xml, the enclosed file is just being downloaded instead of showing the actual sitemap:

image

I'm using October CMS v2.1.24 and the Rainlab Sitemap plugin version 1.1.1. I'm using a mirrored setup. I've followed the Nginx instructions you provided here:
https://docs.octobercms.com/2.x/setup/deployment.html#nginx-configuration

Can you kindly let me know how we can solve this? I'd be happy to provide more details.

Kind regards.

Empty sitemap.xml

Hello! I tried to add custom url or page to sitemap but file still empty...

Incorrectly lists the URLs for unpublished blog posts in the sitemap

The plugin currently adds URLs for blog posts even if they aren't published.

The plugin should either only list the blog posts that are published or it should also add the blog post to the robots file as a URL that shouldn't be visited.

EDIT: This is being reported as I'm seeing URL errors show up in my webmaster console.

Error on sitemap.xml

I am running Octobercms 2.2.25 and plugin version 1.2.0 and I am getting an error on the sitemap.xml whether I add items to the site map or even if it is blank.

The error is

This page contains the following errors:
error on line 2 at column 6: XML declaration allowed only at the start of the document
Below is a rendering of the page up to the first error.

..and nothing else follows

Fails if php-xml not installed

If the plugin is installed on a server that does not have the php-xml installed, it will just fail with an exception, that it cannot find the DOMDocument class.

Class 'DOMDocument' not found
.../plugins/rainlab/sitemap/models/Definition.php line 156

I resolved it by installing php7.0-xml on my instance:

sudo apt-get install php7.0-xml

Would be nice if the plugin could check for that module's existence before installing.

Maximum function nesting level error when building a sitemap with all static pages

We built a site with 100 static pages that only consist of a parent and max one-child navigation.

When we setup the sitemap- we simply added "All Static Pages".

When we attempt to view it- we receive the following error:

2017/06/09 17:13:51 [error] 18455#18455: *4 FastCGI sent in stderr: "PHP message: PHP Fatal error: Maximum function nesting level of '1000' reached, aborting! in /vendor/laravel/framework/src/Illuminate/Support/Arr.php on line 238

Increasing the xdebug.max_nesting_level seems like a bandaid to a bigger problem.

Sitemap is empty, changes aren't saved

I tried to add the sitemap definitions in the backend, but they aren't saved to the database, so when I reload the page, it's empty again. On http://domain/sitemap.xml, all I see is this.
grafik

I read the other issues with the same problem, but I couldn't find a working solution.

Can't create new sitemap

Hi!
I installed your sitemap plugin to my project, but when I tried to add a sitemap, nothing has happend. As I checked in the inspector, some JS files drops error 404. Any ideas what can I do?

Extend / Override plugin

<?php namespace AzatTemirbekUulu\Bloger;
use AzatTemirbekUulu\Bloger\Models\Newz;

class SitemapItem {
    var $changefreq;
    var $priority;
    var $type;
    var $url;
    public function __construct($url)
    {
        $this->changefreq="always";
        $this->priority="0.5";
        $this->type="url";
        $this->url='http://'.$_SERVER['HTTP_HOST']."/news/".$url;
    }
}
class Plugin extends PluginBase{
public function boot()
    {
      \Event::listen('pages.menuitem.resolveItem', function($type, $item, $url, $theme) {
            $list=array();
            foreach (Newz::all() as $item) {
                return (array) new SitemapItem($item->slug);
            }
        });
}
}

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
<url>
<loc>http://localhost:8000/bayiler</loc>
<lastmod>2017-11-20T10:46:48+00:00</lastmod>
<changefreq>always</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>
http://localhost:8000/news/wilke-endustriyel-yag-bloomberg-ht-yayini
</loc>
<lastmod>2017-11-27T11:07:24+00:00</lastmod>
<changefreq>always</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>http://localhost:8000/news</loc>
<lastmod>2017-11-24T11:19:09+00:00</lastmod>
<changefreq>always</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>
http://localhost:8000/news/wilke-endustriyel-yag-bloomberg-ht-yayini
</loc>
<lastmod>2017-11-27T11:07:24+00:00</lastmod>
<changefreq>always</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>http://localhost:8000/*</loc>
<lastmod>2017-11-27T11:07:24+00:00</lastmod>
<changefreq>always</changefreq>
<priority>0.5</priority>
</url>
</urlset>

http://localhost:8000/news/wilke-endustriyel-yag-bloomberg-ht-yayini
is duplicating

Incorrect Sitemap generation

The sitemap includes blog posts that have not been published in to the sitemap.xml which leads the crawlers to a 404 page. This should not happen.

Add support for multiple sitemaps, per theme

This plugin only creates a single sitemap file....?

You need to update this to be able to create multiple sitemaps e.g.

<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
   <sitemap>
      <loc>http://www.example.com/sitemap1.xml.gz</loc>
      <lastmod>2004-10-01T18:23:17+00:00</lastmod>
   </sitemap>
   <sitemap>
      <loc>http://www.example.com/sitemap2.xml.gz</loc>
      <lastmod>2005-01-01</lastmod>
   </sitemap>
</sitemapindex>

Undefined index:

production.ERROR: exception 'ErrorException' with message 'Undefined index: ' in /plugins/rainlab/sitemap/formwidgets/SitemapItems.php:106

This error appears when I go to index page of the plugin in adminpanel.

Rendering of empty pages

Hi all,

When I create a page/sub-page structure, the master pages are shown in the sitemap even if they are empty of any content (in the case of use at the top of a heading).

I can't find an option like in the menus of the 'Static page' plugin to include children instead of the page itself.
Is there an option, or do I need to extend the plugin to include this functionality?

wrong content type

Hi,

My sitemap returns HTML content type instead of XML with the last build (224). Maybe a wrong ngix conf ?

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.