Creating links to assets/resources in markdown

How do I create a link to a file (PDF) in a markdown file that I plan on hosting on my site?

Here’s the options I have gathered so far:

  1. Plop it in /static and serve it from the root even though it has more to do with a specific page than something like robots.txt
  2. Create an _index.md or index.md in a folder and add the file there, then it may be able to be referenced if I generate an HTML template to generate the link then embed it as content in the markdown
  3. Use an inline shortcode and resources.Get to look up the file in the assets directory (or is it a bundle? or data?) then get golang to return the string for rendering into markdown somehow?
  4. Use an existing shortcode (rel? relref? link?) of which there are no examples given anywhere so it’s just randomly firing off attempts until something resolves

Here’s what I’ve tried

[Here's](/assets/somePdf.pdf) the PDF file
[Here's]({{< pdf.inline >}}{{ resources.Get "somePdf.pdf" }}{{< /pdf.inline >}}) the PDF File

I am also using a theme (papermod) which maybe overrides support for linking to files in markdown files, which is quite a surprising limitation.

If the asset will be referenced from only one page, use a leaf bundle.

structure

content/
β”œβ”€β”€ posts/
β”‚   β”œβ”€β”€ post-1/
β”‚   β”‚   β”œβ”€β”€ a.pdf
β”‚   β”‚   └── index.md
β”‚   └── _index.md
└── _index.md

markdown (posts/post-1/index.md)

[link to a.pdf](a.pdf)

If you need to reference the asset from multiple pages, use the assets directory.

structure

assets/
└── docs/
    └── a.pdf
content/
β”œβ”€β”€ posts/
β”‚   β”œβ”€β”€ _index.md
β”‚   └── post-1.md
└── _index.md

site config

[markup.goldmark.renderHooks.image]
enableDefault = true

[markup.goldmark.renderHooks.link]
enableDefault = true

markdown (any page)

[link to a.pdf](docs/a.pdf)
1 Like

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