gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
76.22k stars 7.55k forks source link

String functions within render hooks see HAHAHUGOSHORTCODE #7416

Open jmooring opened 4 years ago

jmooring commented 4 years ago

What version of Hugo are you using (hugo version)?

$ hugo version
Hugo Static Site Generator v0.73.0-DEV/extended linux/amd64 BuildDate: unknown

Does this issue reproduce with the latest release?

Yes

To Reproduce

git clone --single-branch -b hugo-github-issue-7416 https://github.com/jmooring/hugo-testing hugo-github-issue-7416
cd hugo-github-issue-7416
hugo server

Then visit http://localhost:1313/post/test/.

Description

Content page contains the following markdown:

[Other Page]({{< relref "0123456789abcdef.md" >}})

layouts/_default/_markup/render-link.html contains this code:

{{ substr .Destination 0 16 }}

This renders:

HAHAHUGOSHORTCOD

Other

Reported in https://discourse.gohugo.io/t/render-link-functionality-not-working/26358/.

bep commented 4 years ago

The long story short:

You need to use the {{% delimiter in this case.

jmooring commented 4 years ago

Shall I close this as a documentation issue, and submit a documentation PR, or should it be addressed in code?

bep commented 4 years ago

I guess it's both. The best thing to do on the "code side" is to raise an error, I suspect.

jmooring commented 4 years ago

A Google search shows that "HAHAHUGOSHORTCODE" is visible on several live sites. For example:

1) https://developer.servicenow.com/blog.do?p=/categories/now-creator/

image

2) https://www.juliabloggers.com/author/julia-on/

image

We're going to add this to the list of strings that we grep for prior to deployment, but I suspect that's a quality control step that most do not or will not perform.