Can I override TOC setting for only one file in front matter

I have config endLevel for TOC to be 5 in config.toml like

    endLevel = 5
    ordered = false
    startLevel = 2

But there’s only one post I’d like to change endLevel to 4, can I override the markup setting
in the front matter of the post?

I’ve tried this, it seems not working. Is this possible or it there any other way?

title: "post title here"
    endLevel: 4

The configuration is global and does not work on an ad-hoc basis from within a content file.

I would suggest that you hide the last TOC level via some kind of a CSS rule based on a front matter parameter e.g. hide: true

Then either set an inline style or create a dedicated CSS file under /assets/ and use Hugo’s ExecuteAsTemplate to hide the 5th level via the single page template.

In both cases you would need to wrap the CSS rule in something like:
{{ if eq .Params.hide true }}...{{ end }}

Thanks! I’ll try to add CSS to handle this special post.