How to use "Previous post" inside markdown content

Hi there, I’ve been using Hugo for several months, and I’m very happy, thanks for hugo :smiley:

I’m writing a post and I’d like to link to the previous post (inside the markdown), but I cannot find the precise line. Looking at my theme and other themes, I’ve tried different ways of:

In this <a href="{{ .Paginator.Prev.URL }}" target="_new">previous post</a>
In this <a href="{{ .Prev }}" target="_new">previous post</a>

and so on…

The problem is that when I type hugo server, hugo doesn’t seem to convert the “{{ }}” into the proper url. Any hint would be very helpful.

Thanks in advance for your time! :smiley:

Hello @yamila-moreno,

the problem is that Hugo doesn’t treat as templates. Therefore, {{ .Paginator.Prev.URL }} will not return the link to the previous post.

Shortcodes were introduced to fix this limitations. Shortcodes are like small, reusable templates that can be embedded into your content files.

If the prev / next links are at the very end of your post (or a similar position) it might be easier to add them to the actual templates instead.

Hello @digitalcraftsman, thanks for your quick response. Thanks to your link I found rel shortcode which will serve perfectly.