use web server functionality, like redirects/rewrites in .htaccess assuming Apache
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.
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.
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.
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).
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.
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.
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 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.