Slash is added in the result of absURL nad BaseURL

I have used hugo v51 for years and recently tried to upgrade it to v107.

It seems that the newer version of absURL and BaseURL, maybe even more url handling functions, automatically add slash, /, in front of backslash, \, in the URL.

For example, the code is below.

"url": "{{"assets/img/logo.png" | absURL}}" 

Hugo v51 will generate the html like this -

"url": "https://www.example.com/assets/img/logo.png" 

But the html created by Hugo v107 is different -

"url": "https:\/\/www.example.com\/assets\/img\/logo.png" 

Any idea whether it is an intended behaviour? Thanks in advance.

The behavior changed over three years ago beginning with v0.55.0.

Remove the quotation marks around the JSON value. The value will be quoted when rendered. For example:

<script type="application/ld+json">
{
  "url": {{ "assets/img/logo.png" | absURL }}
}
</script>
2 Likes

Thanks, Jooring.

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