Link Search Menu Expand Document

Configuration options

On this page

  1. sortingStrategy
  2. autoHeadMerging
  3. experimentalTitleTokens

To configure the layout dialect, you have 2 options:

  • the constructor with arguments, LayoutDialect(SortingStrategy, boolean)
  • the fluent API methods withAutoHeadMerging, withExperimentalTitleTokens, and withSortingStrategy

Note that the fluent API is currently the only way to enable the experimentatlTitleTokens setting. With the number of options growing, the constructor might be deprecated in favour of the fluent API methods in a future release.

sortingStrategy

Default: ApendingStrategy

new LayoutDialect(new AppendingStrategy());
// or
new LayoutDialect().withSortingStrategy(new AppendingStrategy());

Sets how <head> elements will be sorted when combined from the layout and content templates. See the decorate processor page for more details and examples.

autoHeadMerging

Default: true

new LayoutDialect(null, true);
// or
new LayoutDialect().withAutoHeadMerging(true);

Bypass the layout dialect prforming any <head> element merging altogether. See Bypassing <head> element merging altogether for more details.

experimentalTitleTokens

Default: false

new LayoutDialect().withExperimentalTitleTokens(false);

An experimental option added in 3.4.0 to use standard Thymeleaf expression syntax for title patterns and to have access to the title parts in templates as the variables layoutDialectLayoutTitle and layoutDialectContentTitle (the names are pretty verbose but I want to avoid any potential clashes while I either come up with new ones or some way to configure the names).

So instead of the example in Processors > title-pattern for setting what the final title will look like:

<title layout:title-pattern="$LAYOUT_TITLE - $CONTENT_TITLE">...</title>

You can do this instead:

<title layout:title="|${layoutDialectLayoutTitle} - ${layoutDialectContentTitle}|">...</title>

The title parts will also be made available anywhere in the template as the variables above, so you can reference them as necessary:

<body>
  <p>The title of my page is
    <span th:text="${layoutDialectContentTitle}">(title here)</span>
  <p>
</body>

Any feedback for this experimental option can be made in thymeleaf-layout-dialect/issues/172