Is it possible to create URL that redirect to external website with Hugo

Viewed 45

Simply put, I want social URLs to my blog. For example, when going to www.myWebsite.com/twitter, the user gets redirected to www.twitter.com/username.

I'm also wondering if it's possible to generate them from the theme templates, that'd be neat!

2 Answers

Just put in a redirects section with a twitter.md file. The layout file for the redirect section should look like this:

<html>
<head>
<meta http-equiv="refresh" content="0; url={{ .Params.redirect }}">
</head>
<body></body>
</html>

And the twitter.md file should look like this:

---
title: Twitter
url: https://www.twitter.com/username
---
Related