Markdown nofollow recipes Next.js MDX
Add rel="nofollow" to one link in Next.js MDX
In an .mdx page, write the link as a JSX <a> tag with
rel="nofollow". Don't rely on the same tag in a .md page: @next/mdx
drops it and keeps only the anchor text.
- Next.js 16.4.6 with Turbopack
- @next/mdx 16.4.6
- @mdx-js/loader 3.1.1
- Node.js 24.1.0
- Built on 10 November 2026
Write the link, then build
MDX reads the tag as JSX, so close it and quote the attribute values. It can sit in the middle of a sentence.
You write
app/blog/retry-failed-jobs/page.mdx Record the job ID, attempt number and error. Keep the entries consistent. Logsift's <a href="https://logsift.example/guides/job-logs" rel="nofollow">guide to structured job logs</a> shows a format you can search later.
The build wrote
out/blog/retry-failed-jobs.html <p>Record the job ID, attempt number and error. Keep the entries consistent. Logsift'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>
Next.js escaped the apostrophe in Logsift's as '. The link attributes
came through as written. The test project uses output: "export", so each page
is a static file in out/.
For comparison, the same page has a plain Markdown link to the same guide. The build wrote it like this:
out/blog/retry-failed-jobs.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
The same tag in a .md page disappears
By default, @next/mdx compiles only .mdx files. The Next.js docs show how to
add .md with createMDX({ extension: /\.(md|mdx)$/ }), and the test
project does that. Without it, the .md page stopped the Turbopack build with an
internal error.
With the option set, the build finished, but the <a> tag in the
.md page is gone and only its text is left. Keep pages that need an inline tag
as .mdx.
You write
app/blog/md-page/page.md Record the job ID, attempt number and error. Keep the entries consistent. Logsift's <a href="https://logsift.example/guides/job-logs" rel="nofollow">guide to structured job logs</a> shows a format you can search later.
The build wrote
out/blog/md-page.html <p>Record the job ID, attempt number and error. Keep the entries consistent. Logsift's <!-- -->guide to structured job logs<!-- --> shows a format you can search later.</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 .mdx page prints two tags: the JSX link with rel="nofollow",
then the plain Markdown link.
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.
grep -o '<a [^>]*logsift[^>]*>' out/blog/retry-failed-jobs.html
<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.
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.
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.