OrchardCMS/OrchardCore · error · ArgumentException
page_title tag requires a segment argument
Error message
page_title tag requires a segment argument
What it means
The Liquid `page_title add_segment` tag requires a `segment` argument (the first positional argument or a named `segment:`) because it is the text added to the page title. When `arguments["segment", 0]` resolves to null — no positional or named segment supplied — the tag throws an ArgumentException with this message.
Solutions
- Pass the segment as the first positional argument: `{% page_title 'My Section' %}`.
- Or use the named form: `{% page_title segment:'My Section', position:'2' %}`.
- If the segment comes from a variable, ensure the variable is assigned and non-null before the tag executes.
Example fix
// before
{% page_title position:'2' %}
// after
{% page_title 'My Section', position:'2' %} Defensive patterns
Strategy: validation
Validate before calling
{% if segment == blank %}{% // page_title add_segment requires a non-empty segment %}{% endif %} Prevention
- Always pass the segment as first positional argument or `segment:'...'`.
- Guard dynamic segment variables for null/blank before the tag.
- Watch for typos (`segments:` is not `segment:`).
When it happens
Trigger: Calling `{% page_title %}` with the add-segment style but omitting the segment, e.g. `{% page_title position:'2' %}` with no segment value, or `{% page_title add_segment:true %}` without `segment:`.
Common situations: Copy-pasted title-tag snippets with arguments stripped; a Liquid variable used as the segment that is null/undefined so the named argument lookup misses; typos like `segments:` instead of `segment:`.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- render_section tag requires a name argument
- Cannot override href with other properties
- Format of the link cannot be determined based on the…
- Zone not found while invoking 'render_section':
- An implementation of 'LiquidTemplateContext' is required
AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13).
Data as JSON: /api/errors/c7b831ce1dbaca03.
Report an issue: GitHub.
Appendix: source
Thrown at src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Tags/PageTitleSegmentsTags.cs:41
return Completion.Normal;
}
public static async ValueTask<Completion> WriteAddSegmentAsync(IReadOnlyList<FilterArgument> argumentsList, TextWriter _1, TextEncoder _2, TemplateContext context)
{
var arguments = new NamedExpressionList(argumentsList);
await AddSegmentInternalAsync(arguments, context);
return Completion.Normal;
}
private static async Task<IPageTitleBuilder> AddSegmentInternalAsync(NamedExpressionList arguments, TemplateContext context)
{
var services = ((LiquidTemplateContext)context).Services;
var titleBuilder = services.GetRequiredService<IPageTitleBuilder>();
var segmentExpression = arguments["segment", 0] ?? throw new ArgumentException("page_title tag requires a segment argument");
var segment = (await segmentExpression.EvaluateAsync(context)).ToStringValue();
var positionExpression = arguments["position", 1];
var position = positionExpression == null ? "0" : (await positionExpression.EvaluateAsync(context)).ToStringValue();
titleBuilder.AddSegment(new HtmlString(segment), position);
return titleBuilder;
}
}
View on GitHub (pinned to 4306c0717f)