Geta / geta-optimizely-sitemaps

Search engine sitemaps.xml for Optimizely CMS 12 and Commerce 14

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Geta Optimizely Sitemaps

Quality Gate Status Platform Platform

Search engine sitemaps.xml for Optimizely CMS 12 and Commerce 14

Description

This tool allows you to generate xml sitemaps for search engines to better index your Optimizely sites.

Features

  • sitemap generation as a scheduled job
  • filtering pages by virtual directories
  • ability to include pages that are in a different branch than the one of the start page
  • ability to generate sitemaps for mobile pages
  • it also supports multi-site and multi-language environments
  • ability to augment URL generation

See the editor guide for more information.

Installation

The command below will install Sitemaps into your Optimizely project.

dotnet add package Geta.Optimizely.Sitemaps

The command below will install Sitemaps Commerce support into your Optimizely Commerce project.

dotnet add package Geta.Optimizely.Sitemaps.Commerce

Configuration

For the Sitemaps to work, you have to call AddSitemaps extension method in Startup.ConfigureServices method. This method provides a configuration of default values. Below is a code with all possible configuration options:

services.AddSitemaps(x =>
{
  x.EnableLanguageDropDownInAdmin = false;
  x.EnableRealtimeCaching = true;
  x.EnableRealtimeSitemap = false;
});

You can configure access to the sitemaps configuration tab by adding a custom policy (the default is WebAdmins):

services.AddSitemaps(x =>
{
  x.EnableLanguageDropDownInAdmin = false;
  x.EnableRealtimeCaching = true;
  x.EnableRealtimeSitemap = false;
}, p => p.RequireRole(Roles.Administrators));

And for the Commerce support add a call to:

services.AddSitemapsCommerce();

In order to augment Urls for a given set of content one must prepare to build a service that identifies content to be augmented and yields augmented Uris from IUriAugmenterService.GetAugmentUris(IContent content, CurrentLanguageContent languageContentInfo, Uri fullUri) method.

  1. Create a service that implements IUriAugmenterService yielding multiple Uris per single input content/language/Uri..
  2. Ensure the services is set, overring the default service, within the optionsAction of AddSitemaps. For example:
services.AddSitemaps(options =>
{
    options.SetAugmenterService<SitemapUriParameterAugmenterService>();
});

It is also possible to configure the application in appsettings.json file. A configuration from the appsettings.json will override configuration configured in Startup. Below is an appsettings.json configuration example.

"Geta": {
    "Sitemaps": {
        "EnableLanguageDropDownInAdmin":  true
    }
}

Also, you have to add Razor pages routing support.

app.UseEndpoints(endpoints =>
{
    endpoints.MapRazorPages();
});

Usage

Adding Sitemap Properties to all content pages

Credits to jarihaa for contributing this.

[UIHint("SeoSitemap")]
[BackingType(typeof(PropertySEOSitemaps))]
public virtual string SEOSitemaps { get; set; }

Set default value

public override void SetDefaultValues(ContentType contentType)
{
    base.SetDefaultValues(contentType);
    var sitemap = new PropertySEOSitemaps
    {
        Enabled = false
    };
    sitemap.Serialize();
    this.SEOSitemaps = sitemap.ToString();
}

Ignore page types

Implement the IExcludeFromSitemap interface to ignore page types in the sitemap.

public class OrderConfirmationPage : PageData, IExcludeFromSitemap

Exclude content

If you need more control to exclude content from the sitemap you can make your own implementation of IContentFilter. Make sure to inherit from ContentFilter and call the ShouldExcludeContent method of the base class.

public class SiteContentFilter : ContentFilter
    {
        public override bool ShouldExcludeContent(IContent content)
        {
            if (base.ShouldExcludeContent(content))
            {
                return true;
            }

            // Custom logic here

            return false;
        }
    }

Register in your DI container.

services.AddTransient<IContentFilter, SiteContentFilter>();

Limitations

  • Each sitemap will contain max 50k entries (according to sitemaps.org protocol) so if the site in which you are using this plugin contains more active pages then you should split them over multiple sitemaps (by specifying a different root page or include/avoid paths for each).

Contributing

See CONTRIBUTING.md

Package maintainer

https://github.com/marisks

Changelog

Changelog

About

Search engine sitemaps.xml for Optimizely CMS 12 and Commerce 14

License:Apache License 2.0


Languages

Language:C# 64.1%Language:HTML 23.2%Language:JavaScript 8.3%Language:SCSS 3.6%Language:CSS 0.2%Language:Batchfile 0.2%Language:TSQL 0.2%Language:Shell 0.1%Language:ASP.NET 0.0%