Sha256: 9c315353f752a30019a180f4dae21854c4e44d7bf01a96ea794ecd0520a5bd73

Contents?: true

Size: 895 Bytes

Versions: 1

Compression:

Stored size: 895 Bytes

Contents

# frozen_string_literal: true

module SiteHealth
  # Checks if HTML-meta title is present
  class MissingTitle < Checker
    name 'missing_title'
    types 'html'
    issue_types(
      _default: {
        severity: :major,
        priority: :high,
        links: [{ href: 'https://moz.com/learn/seo/title-tag' }],
      },
      missing: {
        title: 'title missing',
        detail: 'titles are important for SEO',
      },
      too_long: {
        title: 'title too long',
        detail: 'keep titles under 60 characters - titles are important for SEO',
        severity: :medium,
      }
    )

    protected

    def check
      return if page.redirect?

      title = page.title.to_s.strip

      if title.empty?
        add_issue_type(:missing)
      elsif title.length > 60
        add_issue_type(:too_long)
      end
    end
  end

  SiteHealth.register_checker(MissingTitle)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
site_health-0.2.0 lib/site_health/checkers/missing_title.rb