Check if page exists


I just started learning Hugo and found this problem:

I have 3 boxes each with parameter “link” to the other page. How can I check if url in is correct? I want to set href="#" if page from link don’t exists (don’t want 404 in this case).

OR how can i transform param link = “pages/” to url in template ({{< ref >}} do not work)? I assume in this case i can check fileExists?


you can try and use .GetPage to check if the page exists.

Not sure if this suits your use case but you also can use RelRef shortcode

Thank you, i don’t know how i missed that in docs.