How to create an internal link to a file located in the reprository?

Hi,

Lets say I have a .md file in my posts section, and I want to add a link within a paragraph in that file that would lead to another .md file of my choice.

I do not want this .md file to be accessible from anywhere else on the site, just through that link, how would I go about it?

Originally I tried to just add [here](/content/file.md), but clearly that does not work (I believe because it is using a relative path.)

Is this problem theme specific or can it be done on any Hugo site?

Thank you.

Search the documentation for “build options”.

Hey thanks for your reply and that resource. I looked through it, tried some stuff, and am a bit confused.

Changes I made were:

  1. Adding this in the front matter of the destination .md file:
_build:
  list: never
  publishResources: false
  render: link

also tried

_build:
  list: false
  publishResources: false
  render: false
  1. this in the index.html file:
<section id="file">
  {{ with site.GetPage "/content/file" }}
    {{ .Content }}
  {{ end }}
</section>

And now when I click on the specified link in my source file [here](/content/file.md) I am taken to: http://localhost:1313/posts/source/link.com which does not exist. The homepage has also gone completely blank

Any guidance would be much appreciated :pray:

Here’s a simple example:

git clone --single-branch -b hugo-forum-topic-46839 https://github.com/jmooring/hugo-testing hugo-forum-topic-46839
cd hugo-forum-topic-46839
hugo server

Examine these files:

  • content/_index.md
  • content/hidden.md

Thank you so much!!

I was over complicating it by examining files with the layouts folder when I didn’t need to at all, I just needed to fix the absolute path.

Thanks again for your efforts really appreciate it.

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