codingagentlinkbuilding.comby LinkBunny

Markdown nofollow recipes Hugo

Add rel="nofollow" to one link in Hugo Markdown

Add a two-line shortcode that writes the <a> tag with rel="nofollow", then wrap the anchor text with it. Hugo leaves raw HTML out of Markdown by default, so an inline tag doesn't work without a config change.

  • Hugo 0.169.0
  • Built on 10 November 2026

Write the link, then build

Save the shortcode in layouts/_shortcodes/, the folder Hugo's current docs use, then call it in the sentence. The comment on the second line trims the file's trailing newline from the output.

You write

layouts/_shortcodes/nofollow.html
<a href="{{ .Get "href" }}" rel="nofollow">{{ .Inner }}</a>
{{- /* Trim the trailing newline so the link sits inside the sentence. */ -}}
content/blog/retry-failed-jobs.md
Record the job ID, attempt number and error. Keep the entries consistent. Logsift's {{< nofollow href="https://logsift.example/guides/job-logs" >}}guide to structured job logs{{< /nofollow >}} shows a format you can search later.

The build wrote

public/blog/retry-failed-jobs/index.html
<p>Record the job ID, attempt number and error. Keep the entries consistent. Logsift&rsquo;s <a href="https://logsift.example/guides/job-logs" rel="nofollow">guide to structured job logs</a> shows a format you can search later.</p>

Hugo wrote the apostrophe in Logsift's as &rsquo;. The link attributes came through as written.

For comparison, the same page has a plain Markdown link to the same guide. The build wrote it like this:

public/blog/retry-failed-jobs/index.html
<p>Plain Markdown link: <a href="https://logsift.example/guides/job-logs">guide to structured job logs</a>.</p>

Markdown link syntax, [text](url), has nowhere to put a rel, so the plain link has none.

Gotcha

Inline HTML is left out unless you turn on unsafe

Hugo's Goldmark renderer has markup.goldmark.renderer.unsafe set to false by default. The test page also has the link as an inline <a> tag, and the build replaced both of its tags with a comment and kept only the anchor text.

Setting unsafe = true keeps inline HTML on every page of the site. Hugo's docs say that's unsafe unless you control the content. The shortcode keeps the change to the links you wrap.

You write

content/blog/retry-failed-jobs.md
Inline HTML in the same file: <a href="https://logsift.example/guides/job-logs" rel="nofollow">guide to structured job logs</a>.

The build wrote

public/blog/retry-failed-jobs/index.html
<p>Inline HTML in the same file: <!-- raw HTML omitted -->guide to structured job logs<!-- raw HTML omitted -->.</p>

Check the built page before you merge

Run this against the built file. The output below is what the command printed for the test project.

The command prints two tags: the shortcode link with rel="nofollow", then the plain Markdown link. The inline HTML version prints nothing, because the build left it out.

To see every outside link on a page with its anchor text and rel value, paste the built file into the built HTML link audit. It runs in your browser and uploads nothing.

Command
grep -o '<a [^>]*logsift[^>]*>' public/blog/retry-failed-jobs/index.html
Output
<a href="https://logsift.example/guides/job-logs" rel="nofollow">
<a href="https://logsift.example/guides/job-logs">

Sources and what was tested

The test project is one Markdown page with one paragraph, built locally with the versions listed at the top. Every HTML excerpt on this page is copied from that build without edits. Other versions, and plugins that rewrite links, can build different HTML, so check your own output.

LinkBunny, which publishes this site, put the Hugo test project on GitHub under the MIT licence: hboon/hugo-nofollow-fixture. It has the source files, a check for the three links, and a GitHub Actions job that builds it on Linux with Hugo 0.169.0.

Using another generator? See all six recipes.

Next steps with LinkBunny

Placing a LinkBunny exchange link?

LinkBunny exchange links must use nofollow. Your coding agent can follow this recipe when it places one, and the first exchange is free for one site.

Read the agent docs

After the deploy, check the live page

LinkBunny's nofollow link checker fetches a public page and lists each link on it with its rel value, so you can confirm the link survived the deploy.

Open the nofollow link checker