gohugoio / hugo

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

Broken ref in comment causes "ref not found error". #7385

Closed BoltonBailey closed 2 years ago

BoltonBailey commented 4 years ago

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

$ hugo version
Hugo Static Site Generator v0.72.0/extended darwin/amd64 BuildDate: unknown

(I initially was on 0.65.3, then updated and got the same error.)

Does this issue reproduce with the latest release?

Yes.

Minimal working example:

Start a new site as in the quickstart tutorial

hugo new site quickstart
cd quickstart
git init
git submodule add https://github.com/budparr/gohugo-theme-ananke.git themes/ananke
echo 'theme = "ananke"' >> config.toml
hugo new posts/my-first-post.md

Then make the following for content/posts/my-first-post.md

---
title: "My First Post"
date: 2020-06-14T17:04:28-04:00
draft: true
---

This [link]({{<relref "my-first-post.md">}}) works

<!-- This [link]({{<relref "my-nonexistent-post.md">}}) causes the server to fail, even though its commented -->

I get the following error

[en] REF_NOT_FOUND: Ref "my-nonexistent-post.md": "/Users/boltonbailey/Desktop/test/quickstart/content/posts/my-first-post.md:9:18": page not found
Rebuild failed:

Logged 1 error(s)
Hugo Static Site Generator v0.72.0/extended darwin/amd64 BuildDate: unknown

Reload Page
jmooring commented 4 years ago

Wrapping a shortcode call in HTML comments will hide the output, but will not (as you have learned) skip rendering.

If you want to hide the output and skip rendering:

<!-- {{</* shortcode */>}} -->

See: https://discourse.gohugo.io/t/how-to-comment-out-shortcodes-in-markdown/14893/10

Additionally, unless you have set

[markup.goldmark.renderer]
unsafe=true

in config.toml, the HTML comment will be rendered as <!-- raw HTML omitted -->.

Please post your support questions to the Hugo Forum. Thanks.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help. If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open. If this is a feature request, and you feel that it is still relevant and valuable, please tell us why. This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.