Front matter URL with absolute URL

Is it possible to give an absoulyte URL in the font matter? For example:

url: ""

Instead of linking to a relative page. Because if I do the above one I get an error saying Only relative URLs are supported,

My understanding is that it can only be relative URLs, and I guess it’s understandable: Hugo is building only the one site, not some other site.

Ya that’s true, is there any way we can link it to an external site?

What’s the use case? Just trying to understand…

If you need a given url path to redirect at another site, I guess you could:

By the way, Hugo is consistent regarding this behavior: you can’t set the aliases frontmatter param or the url, to point at something outside the site.

So for example, creating a multiple files, say under posts we can list the relative urls of these files in list.html and also it creates an html page for each of those links right?

So sometimes I want to link them to an external site rather than generate a new html page. In the sense, I would rather link some project to an external page (say GithHub) instead of using an data such as JSON file to list of the links and keeping the way hugo kinda work but without generating those html pages.

I believe making pages from data (that is, not just data points or grids but actual separate pages) is on the roadmap and might fit what you are trying to do.

Search the forum for e.g.:

Ya but this would still creates an extra html page for each data entry right? Which would be a waste of space (even though it’s tiny) when the page is connected (or redirected) to the external link.

How would you do this, without some kind of manifest? Hugo can automatically generate from something that exists (taxo pages from taxo entries in frontmatter) but, you would have to make some kind of list to tell it to create a structure to redirect certain url paths. The manifest could be a future data-to-pages scheme built into hugo some day, or, a list of redirects in an .htaccess file (possible now), for example.

@akshaybabloo you can do what you want, just not with the url in front matter, as that already has special meaning in Hugo. Try externalUrl instead, it will work for what you want.

1 Like

Totally missed that one, sorry.

Edit: @maiki oh, so you mean to make up a param to hold the url, then do what is needed with it, right?

I don’t think it does what the OP actually wants, which is that generate links from a data file and range over it with local posts thing everyone wants. But it is the fix to the issue they were trying to address in the original post.


1 Like

Is there a list of words with special meaning that can be referred to?

They are predefined front matter variables, and they are listed at Front Matter | Hugo. :slight_smile:

When I mentioned a variable called externalUrl, I was referring to a user-defined variable:

You can add fields to your front matter arbitrarily to meet your needs.

1 Like

It’s like creating a custom variable and just using it right, as of now I am doing that, but I think the pages are still created so I am just ignoring them in the sitemap.xml (it’s a custom one).

I think this should be a feature request?

My response was to answer the original question, because folks will search for that. The thing you want, to create a list of URLs and include them in a listing, that can be done with data templates. My recommendation: play around with data templates, see if you can get the output you are looking for, and then create a new #support ticket if you hit a wall. :slight_smile:

Okay. thanks.

Hi maiki–

I am hoping to link to an external site (datasheet pdf) from the sidebar of my Hugo site, and I was wondering if you had any tips about creating this externalUrl ‘user-defined variable’. I’ve looked around a bit on the variables page of the Hugo site, and I’m still not entirely sure how to get started.

Thanks for your help! :slight_smile:

1 Like

Welcome to the Hugo forums. :slight_smile:

If you want to only link to a PDF from the sidebar of a single post, for instance, you’d use front matter to define your URL, as documented at Front Matter | Hugo. Then, you render that in your sidebar template, referencing the front matter param you define value, as documented at Introduction to Hugo Templating | Hugo.

If on the other hand you want to configure it to always be in your sidebar, you might define the PDF URL in your site params, as documented at Site Variables | Hugo. That is basically done the same way, you then editing your sidebar template to add the HTML link based on your .Site.Params. In fact, that’s how many themes work, they have theme-specific site params for links such as social media, and then they use those params to create a footer menu of links, for example.

Good luck! :slight_smile: