Absolute url in hugo website front matter _index.md file

873 views Asked by At

I'm stuck at the following issue being a new in Hugo. I want to redirect URL to a absolute URL rather than relative url. Here is what I means. In _index.md file

# Display name
title: mohit kumar
url: ranveeriit.github.io/

Assume base URL is https://eample.com. As such, hugo redirects me to https://example.com/ranveeriit.github.io/ what I want hugo to redirect to ranveeriit.github.io/ when I click the mohit kumar under meet the team at https://chandu8542.github.io/. I'm using hugo wowchemy academic theme.

1

There are 1 answers

2
I'M YourOnly.One On

You have to edit your theme's /layouts/ files to add support to your particular use-case.

  1. It may be in index.html or list.html or some other file, depending on how your theme split up their code.

  2. Look for the <a href=""> part. It more likely looks like <a href="{{ .Permalink }}"> or <a href="{{ .RelPermalink}}">.

  3. Change it to something like: <a href="{{ with .Params.link }}{{ . }}{{ else }}{{ .Permalink }}{{ end }}">.

  4. Then in your .md file, add the link frontmatter param. It should look similar to this:

---
link: https://example.com
---