ZauberCMS
  • 🪄Welcome to ZauberCMS
  • Getting Started
    • 💡Quick Start
      • Databases
  • Creating A Website
    • 📹Website Build Video Tutorial
    • Content Types
      • Element Types
      • Compositions
    • Current Content Properties
      • Textbox & Textarea
      • Text Editor (Radzen)
      • Text Editor (TinyMCE)
      • Numeric
      • True / False
      • Rating
      • Checkbox, Dropdown & Radio Lists
      • Media Picker
      • Navigation
      • Material Icon Picker
      • Content Picker
      • Date Picker
      • Custom Component Picker
      • Api Key Picker
      • Colour Picker
      • Block List Editor
      • Editor Notes
      • Google Map Location Picker
      • Simple List Manager
      • Simple Dictionary Manager
      • SEO Property
      • Code Editor
      • Colour Theme Picker
    • Content
      • Publish & Unpublish
    • Querying Data
      • Extension Methods
    • Views
    • Controllers (Route Hi-Jacking)
    • Custom Components
    • Users & Roles
      • Restrict Access By Role
    • Logs
    • Audit
    • Global Settings
      • Using Global Settings
    • SEO Sitemaps
    • Hosting
  • Extending ZauberCMS
    • Overview
    • BlockListEditor
      • Content Block Preview
      • Content Block
    • Custom List Data
    • Custom Content Property
    • Custom Validation
    • Custom Admin Sections
      • Section Nav Group Menu
      • Trees
        • Tree Context Menus
      • Reusing Content Editors
    • Saving Custom Data
    • Using AppState Events
    • Before & After Save
    • Email & Storage Providers
    • Seed Data
    • SEO Checks
  • Identity
    • Overview
    • External Authentication Providers
    • Account Layout
  • Language
    • Overview
    • Adding Language Dictionaries
    • Setting The Language
    • Using Language Dictionaries
  • AppSettings
    • Detailed Errors
    • Media Settings
    • Enable Path Urls
Powered by GitBook
On this page
  1. Extending ZauberCMS

SEO Checks

PreviousSeed DataNextOverview

Last updated 3 months ago

The SEO checker lets you put in a Url and run specific checks on the page to make sure you are using best practices. It's also part of the SEO Property.

The SEO Checker comes with a number of checks out of the box, but you can easily create your own. Just create a class that implements ISeoCheck

public interface ISeoCheck
{
    string Name { get; }
    Task<SeoCheckResult> Check(string url, HtmlDocument document, Content.Models.Content content);
    int SortOrder { get; }
}

The example below shows the built in H1 checker that checks if the H1 is missing or if you have more than one H1 tag.

public class HeadingOneSeoCheck : ISeoCheck
{
    public string Name => "H1 Checker";
    public Task<SeoCheckResult> Check(string url, HtmlDocument document, Content.Models.Content content)
    {
        var result = new SeoCheckResult(Name);
        var seoItem = new SeoCheckResultItem();

        // Select all H1 elements
        var h1Tags = document.DocumentNode.SelectNodes("//h1");

        if (h1Tags == null || h1Tags.Count == 0)
        {
            seoItem.Status = SeoCheckStatus.Error;
            seoItem.Message = "Page is missing an <h1> heading tag.";
            result.Items.Add(seoItem);
        }
        else if (h1Tags.Count > 1)
        {
            seoItem.Status = SeoCheckStatus.Warning;
            seoItem.Message = $"Page contains multiple <h1> tags ({h1Tags.Count}). Consider reducing to one for better SEO.";
            result.Items.Add(seoItem);
        }


        return Task.FromResult(result);
    }
    
    public int SortOrder => 1;
}
SEO Checker built into the SEO Property