# \`.Page.RenderString\` does not resolve reference style links in shortcodes

**URL:** <https://discourse.gohugo.io/t/page-renderstring-does-not-resolve-reference-style-links-in-shortcodes/45749>\
**Category:** support\
**Created:** [August 15, 2023, 4:45pm UTC](https://discourse.gohugo.io/t/page-renderstring-does-not-resolve-reference-style-links-in-shortcodes/45749 "2023-08-15T16:45:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![UtkarshVerma](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/utkarshverma/32/11273_2.png) [@UtkarshVerma](https://discourse.gohugo.io/u/UtkarshVerma)\
**Post date:** [August 15, 2023, 4:45pm UTC](https://discourse.gohugo.io/t/page-renderstring-does-not-resolve-reference-style-links-in-shortcodes/45749/1 "2023-08-15T16:45:19Z")

</div>

I have the following `table` shortcode:

```plaintext
{{ $caption := "" }}
{{ with .Get "caption" }}
  {{ $caption = printf `<caption class="text-center">%s</caption>` . }}
{{ end }}

{{ $class := "" }}
{{ with .Get "class" }}
  {{ $class = . }}
{{ end }}
{{ with .Get "small" }}
  {{ $class = print $class "table-sm" }}
{{ end }}

<div class="table-responsive extra-wide">
  {{ .Page.RenderString .Inner |
    replaceRE "<table>" (printf `<table class="table %s mb-0">%s` $class $caption) |
    replaceRE "<tbody>" `<tbody class="table-group-divider"` |
    safeHTML
  }}
</div>

```

I’m trying to use Markdown’s [reference style links](https://www.markdownguide.org/basic-syntax/#reference-style-links) within the inner content of the table shortcode as follows:

```md
{{< table small=true >}}

| Field | Description |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id` | Tag ID specified in the [wiki][mbox-propif]. |
| `buffer_size` | Size of the buffer (not the tag) in bytes. |
| `status` | Tag status: <ul><li>Bit 31 should be cleared for requests.</li><li>In responses, bit 31 is set and bits `[30:0]` indicate the response buffer size.</li></ul> |

{{< /table >}}

```

However, the shortcode does not resolve the [mbox-propif] reference link. How do I get this to work?

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [August 15, 2023, 5:28pm UTC](https://discourse.gohugo.io/t/page-renderstring-does-not-resolve-reference-style-links-in-shortcodes/45749/2 "2023-08-15T17:28:08Z")

</div>

You need to define the link target within the shortcode call.

```auto
{{< table small=true >}}

| Field | Description |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id` | Tag ID specified in the [wiki][mbox-propif]. |
| `buffer_size` | Size of the buffer (not the tag) in bytes. |
| `status` | Tag status: <ul><li>Bit 31 should be cleared for requests.</li><li>In responses, bit 31 is set and bits `[30:0]` indicate the response buffer size.</li></ul> |

[mbox-propif]: https://gohugo.io
{{< /table >}}

```

---

<div class="post-metadata">

**Author:** ![UtkarshVerma](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/utkarshverma/32/11273_2.png) [@UtkarshVerma](https://discourse.gohugo.io/u/UtkarshVerma)\
**Post date:** [August 15, 2023, 5:33pm UTC](https://discourse.gohugo.io/t/page-renderstring-does-not-resolve-reference-style-links-in-shortcodes/45749/3 "2023-08-15T17:33:06Z")

</div>

Thanks. Is there an alternative where the definition can be read from the page context? I use that reference as plain text in the document as well.

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [August 15, 2023, 5:36pm UTC](https://discourse.gohugo.io/t/page-renderstring-does-not-resolve-reference-style-links-in-shortcodes/45749/4 "2023-08-15T17:36:10Z")

</div>

> [@UtkarshVerma](#):
>
> Is there an alternative

No. The `.Page.RenderString` method passes the string through the markdown renderer, and the markdown renderer can’t see the link target unless it’s part of the string.

---

<div class="post-metadata">

**Author:** ![UtkarshVerma](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/utkarshverma/32/11273_2.png) [@UtkarshVerma](https://discourse.gohugo.io/u/UtkarshVerma)\
**Post date:** [August 15, 2023, 5:49pm UTC](https://discourse.gohugo.io/t/page-renderstring-does-not-resolve-reference-style-links-in-shortcodes/45749/5 "2023-08-15T17:49:05Z")

</div>

Okay, thanks for the information.

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [August 17, 2023, 5:49pm UTC](https://discourse.gohugo.io/t/page-renderstring-does-not-resolve-reference-style-links-in-shortcodes/45749/6 "2023-08-17T17:49:40Z")

</div>

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