Url List

The UrlListModule provides the facility for url management, redirecting urls and changing the 'natural' url of a content item to an arbitrary url. It provides for a section in the editor to manage urls for every relevant content item. It also manages generation of canonical urls.

Configuring the Url List module

.UseModule<UrlListModule>()

.UseModule<UrlListModule>((Func<Type, bool>)(t => !(new Type[] { typeof(User) }.Contains(t))))

The url list module has an optional appliesToType parameter which is a function from type to boolean which is true if content of the given type should have UrlList data.

The url list module has the following settings:

  • AlwaysUseCanonical: insert a rel=canonical link into every page, even if the url of the page is the canonical url. Defaults to true.
  • DefaultCanonicalDomain: the domain name of the default domain to use for generating canonical links (e.g. www.awebsite.com). Defaults to null, in which case the domain of the current request is used.
  • UseHttpAlways: if true, always use http: at the beginning of the domain, if false, always use https:, if null use the same as the current request. Defaults to null.
  • SafeReload: if true (the default), when reloading the cache, retains the old cache in memory alongside the one being reloaded and only switches them when loading is done.  Set false to save memory. Defaults to true.

Ensuring a content type can have a url list

To have a url list, a content type must implement IHasAlternateUrls.  A possible way to ensure that is if it inherits from PageWithUrlsContent (which in turn inherits from PageContent).

The Url List editor section

When set up, the editor shows an editor section for managing urls for all appropriate content types. You can add or delete a url as normal with a list editor.  The url itself is entered, then a selection is made from:

  • Main: This can only be selected once in the list.  When this is selected, the primary url to access the content item is the given one, not the 'natural' one given by the data route template. Within Lynicon, references to the url of the item will return the primary url.  While it is still possible to view the content item on the 'natural' url, the page markup has a canonical link to the given url.
  • Canonical: The page can be accessed additionally on the url supplied, however it has a canonical tag pointing to the 'natural' url
  • 301: Accessing the url listed results in a 301 redirect to the natural url
  • 302: Accessing the url listed results in a 302 redirect to the natural url

Adding Canonical tag to page templates

This is done with a line or Razor as follows:

<link rel="canonical" href="@Url.Canonical()" />