# Orchardcore Autoroute

> Skill for configuring AutoroutePart in Orchard Core. Covers URL pattern syntax using Liquid expressions, AutoroutePartSettings, SEO-friendly slugs, hierarchical container routing, home page routing, route conflict resolution, and programmatic route management. Use this skill when requests mention Orchard Core AutoroutePart, Configure AutoroutePart, AutoroutePartSettings Properties, Migration Pattern, Enabling AutoroutePart via Recipe, Content Type Definition with AutoroutePart via Recipe, or closely related Orchard Core implementation, setup, extension, or troubleshooting work. Strong matches include work with OrchardCore.Autoroute, OrchardCore.Contents, OrchardCore.Autoroute.Services, AutoroutePart, AutoroutePartSettings, TitlePart. It also helps with autoroute examples, Enabling AutoroutePart via Recipe, Content Type Definition with AutoroutePart via Recipe, Common Liquid URL Patterns, plus the code patterns, admin flows, recipe steps, and referenced examples captured in this skill.

- Skill: `crestapps/orchardcore-autoroute` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add crestapps/orchardcore-autoroute`
- Raw SKILL.md: https://api.skillmd.com/api/skills/crestapps/orchardcore-autoroute/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Marketing & Growth
- License: Apache-2.0
- Author: CrestApps (https://skillmd.com/u/crestapps)
- Updated: 2026-09-10
- Page: https://skillmd.com/skills/crestapps/orchardcore-autoroute

---


# Orchard Core AutoroutePart - Prompt Templates

## Configure AutoroutePart

You are an Orchard Core expert. Generate code and configuration for AutoroutePart URL routing.

### Guidelines

- AutoroutePart generates SEO-friendly URLs (permalinks) for content items based on Liquid patterns.
- The default URL pattern is `{{ ContentItem | display_text | slugify }}`, which derives the slug from the content item's display text.
- AutoroutePart requires `TitlePart` (or another display text source) to be attached to the content type for `display_text` to resolve.
- Enable the `OrchardCore.Autoroute` feature before using AutoroutePart.
- Set `AllowCustomPath = true` to let editors override the generated URL with a custom path.
- Set `ShowHomepageOption = true` to allow editors to designate a content item as the site home page.
- Orchard Core automatically appends a numeric suffix (e.g., `-1`, `-2`) when a generated slug conflicts with an existing route.
- Liquid patterns have access to `ContentItem` properties including `ContentType`, `DisplayText`, `CreatedUtc`, and all attached part data.

### AutoroutePartSettings Properties

| Property | Type | Description |
|---|---|---|
| `Pattern` | `string` | Liquid template that generates the URL path. |
| `AllowCustomPath` | `bool` | When `true`, editors can manually enter a custom URL. |
| `ShowHomepageOption` | `bool` | When `true`, a checkbox appears to set the item as the site home page. |
| `AllowDisabled` | `bool` | When `true`, editors can disable autoroute generation for individual content items. |
| `AllowAbsolutePath` | `bool` | When `true`, allows paths that start with `/` to be treated as absolute. |

### Migration Pattern

```csharp
public sealed class Migrations : DataMigration
{
    private readonly IContentDefinitionManager _contentDefinitionManager;

    public Migrations(IContentDefinitionManager contentDefinitionManager)
    {
        _contentDefinitionManager = contentDefinitionManager;
    }

    public int Create()
    {
        _contentDefinitionManager.AlterTypeDefinition("{{ContentTypeName}}", type => type
            .DisplayedAs("{{DisplayName}}")
            .Creatable()
            .Listable()
            .Draftable()
            .Versionable()
            .WithPart("TitlePart", part => part
                .WithPosition("0")
            )
            .WithPart("AutoroutePart", part => part
                .WithPosition("1")
                .WithSettings(new AutoroutePartSettings
                {
                    AllowCustomPath = true,
                    ShowHomepageOption = true,
                    Pattern = "{{ ContentItem | display_text | slugify }}"
                })
            )
        );

        return 1;
    }
}
```

### Enabling AutoroutePart via Recipe

```json
{
  "steps": [
    {
      "name": "Feature",
      "enable": [
        "OrchardCore.Autoroute",
        "OrchardCore.Contents"
      ],
      "disable": []
    }
  ]
}
```

### Content Type Definition with AutoroutePart via Recipe

```json
{
  "steps": [
    {
      "name": "ContentDefinition",
      "ContentTypes": [
        {
          "Name": "Article",
          "DisplayName": "Article",
          "Settings": {
            "ContentTypeSettings": {
              "Creatable": true,
              "Listable": true,
              "Draftable": true,
              "Versionable": true
            }
          },
          "ContentTypePartDefinitionRecords": [
            {
              "PartName": "TitlePart",
              "Name": "TitlePart",
              "Settings": {
                "ContentTypePartSettings": {
                  "Position": "0"
                }
              }
            },
            {
              "PartName": "AutoroutePart",
              "Name": "AutoroutePart",
              "Settings": {
                "ContentTypePartSettings": {
                  "Position": "1"
                },
                "AutoroutePartSettings": {
                  "AllowCustomPath": true,
                  "ShowHomepageOption": true,
                  "Pattern": "{{ ContentItem | display_text | slugify }}"
                }
              }
            }
          ]
        }
      ]
    }
  ]
}
```

### Common Liquid URL Patterns

```text
# Simple slug from display text
{{ ContentItem | display_text | slugify }}

# Prefixed with content type
{{ ContentItem.ContentType | downcase }}/{{ ContentItem | display_text | slugify }}

# Date-based blog pattern
{{ ContentItem.CreatedUtc | date: '%Y' }}/{{ ContentItem.CreatedUtc | date: '%m' }}/{{ ContentItem | display_text | slugify }}

# Category prefix from a taxonomy field
{% assign terms = ContentItem.Content.Article.Category.TermContentItemIds | terms %}
{% for term in terms %}{{ term | display_text | slugify }}/{% endfor %}{{ ContentItem | display_text | slugify }}
```

### Programmatic Route Management

Use `IAutorouteEntries` to look up and manage route entries programmatically:

```csharp
using OrchardCore.Autoroute.Services;

public sealed class RouteService
{
    private readonly IAutorouteEntries _autorouteEntries;

    public RouteService(IAutorouteEntries autorouteEntries)
    {
        _autorouteEntries = autorouteEntries;
    }

    public async Task<string> GetContentItemIdByPathAsync(string path)
    {
        (var found, var entry) = await _autorouteEntries.TryGetEntryByPathAsync(path);

        if (found)
        {
            return entry.ContentItemId;
        }

        return null;
    }
}
```

### Home Page Routing

When `ShowHomepageOption` is enabled and an editor marks a content item as the home page, Orchard Core routes the site root URL (`/`) to that content item. Only one content item can be the home page at a time; setting a new home page automatically unsets the previous one.

