External link for another section than Project in Hugo Academic

Hi all,

I am fairly new to Hugo and coding. In Hugo Academic, there is the possibility to add an “external link” in the “project” section. By adding an external link, clicking on the project name on the homepage opens directly a new tab with the link inserted in “external link”.

What I would like to do is to have the exact same option but for the section “Post”. I tried to play around with the post.html in the layout folder but my coding skills are so poor I cannot bring myself to add this simple “external link” option.

Can someone help?
Thank you,
Christophe

I have a bit of trouble following you. :slight_smile: I suppose that when you say ‘section Post’, you mean the part of the theme’s homepage that lists recent posts?

I ask because in Hugo sections have a special meaning. So I’m not sure if we’re on the same page.

I think it is a section as it belongs in the content folder. But yes it is called “recent posts”on the homepage. The other “sections” on my webpage are “publications”, “upcoming talks”, “projects”, “tags” and “contacts”.

In that case you’ll need to change this line from the theme’s post_li_detailed.html file from:

<a href="{{ $post.Permalink }}" itemprop="url">{{ $post.Title }}</a>

to

<a href="{{ $post.Permalink }}" itemprop="url" target="_blank">{{ $post.Title }}</a>

That change will make the posts listed in ‘Recent Posts’ from the homepage open in a new tab, just like what you described with ‘external links’.

Thank you! However, this is not exactly what I wanted.

Here is the demo for Academic Hugo: https://themes.gohugo.io/theme/academic/
Under Projects, the two examples “deep learning” and “external project” open differently. The choice is made in the example-external-project.md with the line:

 # Optional external URL for project (replaces project detail page).
 external_link = "[http://example.org](http://example.org/)"

I would like to have the same option (open external link directly or internal link) for the “New Posts”.

In \layouts\project, the single.html has the following line:

 {{ with .Params.external_link }}
    <a class="btn btn-primary btn-outline" href="{{ . }}" target="_blank" rel="noopener">{{ i18n "open_project_site" }}</a>
    {{ end }}

However, I cannot figure out how to copy/paste that line in the post_li_detailed.html.