How can I redirect to an external link on click of header of any blog?

#1

Hi,

I am very new to hugo. How can I redirect to an external link on click of the header of any blog?
Currently, it is redirecting me to the details page of that blog. I want to change this flow and redirect it to some external link.

Thanks

#2

Please read about requesting help, and add more details. Focus on one question at a time.

#3

That’s a matter of editing the template or templates, and depending on your code, it could be any of several places you need to edit to make that work. As @maiki mentions, give us more info on your site/code and we can direct you.

#4

I have added multiple posts to post folder which is displayed as a list. I want to redirect to medium pages on click of the header of those post.

In the above screenshot, on click of the header of any blog, I want to redirect to some medium link (https://medium.com/).

The theme I am using is hugo-geo.

#5

Instead of {{ .Permalink }} you need to put the Medium URL.

You can override the theme by copying its files to the equivalent location in your project.

You could make a key:value in your pages’ frontmatter to hold the Medium URL, and pull that into the template, instead of the page’s permalink.

1 Like
#6

This works.
I replaced the below line in summary.html

href="{{ $.Params.affiliatelink }}

and added

affiliatelink = "https://medium.com"

in the posts.
Thank you :slight_smile: