HtmlElementAuditor

The info.magnolia.services.seo.audit.impl.HtmlElementAuditor checks for the presence of a specified HTML element. If the HTML element is found at least once, the audit passes, otherwise the audit fails. This auditor can be applied to any renderable node. The auditor uses jsoup queries to parse and find HTML elements. These queries have a jQuery or CSS like syntax.

Class

info.magnolia.services.seo.audit.impl.HtmlElementAuditor

Properties

In addition to the common auditor properties, this auditor can be configured with the following properties:

Property Description

level

required

Determines how a failed audit will be counted:

  • Error (auditErrors)

  • Warning (auditWarnings)

  • Note (auditNotes)

auditProperty

required

Defines the property name for storing failed audit results.

The property name should be unique among auditors or auditors may overwrite results.

auditValue

required

Defines a message or explanation for a failed audit.

The message can have placeholders that are replaced with information about the node and auditor:

  • 0 - node path

  • 1 - configured query property

query

required

A valid jsoup query. See this cookbook for more on jsoup queries.

fetcher

required

Added in v5.6.5.

Defines the content fetcher for the selected node. The query is then applied to the fetched content.

There are two types of content fetchers available.

valuePattern

optional

If defined, this pattern will be applied to the returned results of the jsoup query. If the pattern does not match a result, then an audit result of level will be marked.

valueFlags

optional

Added in v5.6.5.

Regular expression bit flags for matching. The flags will be applied with any regular expression defined by valuePattern and ignored otherwise.

The valueFlags value should correspond to the match flags defined in java.util.regex.Pattern (see https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html)

invalidValue

optional, required if valuePattern is defined

Defines a message or explanation if a query result does not match valuePattern.

The message can have placeholders that replaced with:

  • 0 - query result

  • 1 - valuePattern

textOnly

optional

Added in v5.6.5.

Controls the text searched by valuePattern.

  • If set to true, the text will be stripped of all HTML tags and only the the values of HTML tags will be used.

  • If set to false (the default), the full text including all HTML tags, will be searched.

Example

Here is an example from the SEO module. You can find this configuration here: /modules/seo/config/auditManager/auditors/titleRendered.

titleRendered:
  auditProperty: titleNotRendered
  auditValue: The head title is not rendered in the page {0}
  class: info.magnolia.services.seo.audit.impl.HtmlElementAuditor
  description: Check if the title is rendered (pre-prod)
  invalidValue: The head title is not properly rendered: {0}
  level: auditErrors
  query: title
  valuePattern: .{1,}
  fetcher:
    class: info.magnolia.services.seo.audit.impl.RequestFetcher
    targets:
      localhost:
        class: info.magnolia.services.seo.audit.impl.HostTarget
        host: localhost
        password: superuser
        port: 8080
        scheme: http
        user: superuser
Feedback

Incubators

×

Location

This widget lets you know where you are on the docs site.

You are currently perusing through the SEO module docs.

Main doc sections

DX Core Headless PaaS Legacy Cloud Incubator modules