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 | ||
---|---|---|---|
|
required Determines how a failed audit will be counted:
|
||
|
required Defines the property name for storing failed audit results.
|
||
|
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:
|
||
|
required A valid jsoup query. See this cookbook for more on jsoup queries. |
||
|
required
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. |
||
|
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. |
||
|
optional
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) |
||
|
optional, required if Defines a message or explanation if a query result does not match valuePattern. The message can have placeholders that replaced with:
|
||
|
optional
Controls the text searched by valuePattern.
|
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