Suppress the use of "lang" in front mattter

I have a bunch of pages that I also convert to PDF. Pandoc required the “lang” attribute but it:

  1. give a warning in hugo
  2. still overrides the default content if its not set correctly.

When is this going to be removed from hugo?

I would love for hugo to ignore it today…

The warning was removed in the latest Hugo release:

bep is referring to a superfluous warning that we recently removed.

In your case, given this front matter in a .pdc file:

---
title: Post 1
lang: fr
---

Hugo emits this warning:

WARN deprecated: lang in front matter was deprecated in Hugo v0.144.0 and will be removed in a future release.

We emit a similar warning if you specify kind or path in front matter. We will continue to warn until approximately v0.159.0 at which point we will throw an error. More about deprecation here.

To pass a lang attribute when running the pandoc exec, you need to do this:

---
title: Post 1
params:
  lang: fr
---

Then create a pandoc filter:

map-lang.lua (base file name is irrelevant)
function Pandoc(doc)
  local meta = doc.meta
  if meta.params.lang then
    meta.lang = meta.params.lang
  end
  return doc
end

Then run pandoc with the filter. For example:

pandoc content/posts/post-1.pdc --lua-filter map-lang.lua --standalone 
3 Likes

I understand that solution, however, Pandoc understands lang in the front matter out of the box with no additional configuration files… along with other options.

I do not think that lang should throw an error. That seams unessesary.

If it were unnecessary we wouldn’t have done it.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.