[SOLVED] Relative link to markdown file from config.toml

#1

Hello,

Very basic question, but haven’t been able to solve. Missing some fundamentals about hugo I’m guessing…

In my config.toml, I have:

  # Links
  [[params.links]]
    [params.links.list1]
      heading = "About"

      [[params.links.list1.link]]
        text = "Updates"
        url = "/content/updates.md"

      [[params.links.list1.link]]
        text = "Services"
        url = "/content/services/"

      [[params.links.list1.link]]
        text = "Contact"
        url = "content/contact/"

My directory structure is:
/ root
- netlify.toml
- site/
– config.toml
– content/
— updates.md
— services.md
— contact.md
– static/
– themes/
– etc.

Anyway, the problem is for the url fields above I can’t seem to link to the file. The files exist in the content/ folder.

I tried using the relref and ref shortcodes, but I believe those are meant for using within an .md file, not in a .toml file.

I tried a few variations of the relative link, but can’t seem to get it to work.

I’m sure the answer is very simple!

#2

Try to leave content out. The path e. g. to the updates page is /updates/.

#3

Hm… that didn’t work.
I changed the url to simply “/updates/”, no go.
I also tried copying updates.md to static/ rather than content/, no go either.

#4

Why do you want to link to a markdown file and not the generated .html file?

If you’re able to share your git repository that would help. Links to /updates, /services etc. should work.

#5

That’s a great question… I suppose I definitely want hugo to take that markdown file and generate an HTML file for me and then link to that.

Have it private on gitlab but just uploaded a copy here:
https://github.com/4b11b4/temp-fft-hugo

You’re going to want to look at:
site/config.toml and look for the “links” section towards the bottom.
I don’t have an “updates” or “services” but I link to “p1” instead.
This “p1.md” file exists in site/content/ as well as site/static/ but hugo doesn’t seem to be generating the HTML or my links in the config.toml are incorrect.

The site is live at fft.farm and you can click the “Phase One”, “Phase Two”, etc links to test.
The github repo I linked above is the same as the live version (as of posting this).

#6

@4b11b4 the menu system is normally used after you know what you are adding to it. That means ensuring all your content is in the correct place, and is rendering correctly. The example you’ve shared is linking to documents that don’t exist in any form (content/updates.md isn’t present in your repo).

You need to get your content in order, ensure it is showing correctly, and then work on the menu. :slight_smile:

#7

In the 1st post I gave the example of “updates.md” but I am actually using a different file.
Sorry, confusing…

The only file I have attempted to link to so far is “p1.md” which I originally created at content/p1.md (also later tried copying to static/).

The github repo I linked above should reflect that as far as:

  • the files existing and
  • the config.toml attempting to link to some form of “p1” in the 2nd menu item
#8

Side note:
In the bottom half of the config file there are the three “#Links Lists”

If you look closely the order goes 1, 3, 3… I fixed this in the actual repo for netlify,
…but that mistake apparently didn’t cause any issues? or fix anything either?

#9

Does it have something to do with the theme?
Can a theme tell hugo to only generate one HTML file?
It is called the… “one page split theme”

#10

@4b11b4, this is why we have Requesting Help, because had you followed the advice there, we would have immediately let you know what was happening and what you need to do. Please review that post and keep it in mind for next time.

Here’s what you need to do: find or modify a theme to generate the content in the way you want. Your content is all markdown files, and they live in content. When you get a piece of content showing up at an expected URL, then you are ready to add the URL to the menu system.

#11

Fair enough. Thanks maiki.
I read through that page and will include all of that information in the first post next time.

I will set up a new hugo environment with one of the tutorials, get some pages linked to, and then try to switch the theme so I can see if that is the issue.

#12

Out of curiosity though - themes are able to tell hugo to render files in the content/ folder? or to not render these files?

#13

So I think the ‘problem’ is the theme. It’s a single page theme. The first line in its readme says…

Split is a single page, centrally-divided layout for a professional online presense with a big image or video left with alongside content.

And if you look in the layouts/_default directory, both single.html and list.html are empty files. This means that hugo doesn’t have any information about how to render anything other than the landing page (index.html).

So if you want a website with more than one page, you’ll either need to choose a different theme, or fork/extend the hugo-split-theme to display pages.

Another thing I noticed is that you haven’t included the theme as a submodule, which is necessary if you’re hosting on netlify.

#14

Sorry - posted just after your question. The short answer is yes (see above :slight_smile:)

#15

Thanks. This makes much more sense. Thank you very much. I need to learn to be able to read a theme to see what it generates.

I did add it as a submodule for the actual netlify repo, when I copied the files to github for showing ya’ll (thank you by the way), I just straight up copied it.