Read more link anchor

Hi all,

First - love using Hugo and thanks for all the hard work making it awesome!

I’ve done quite a bit of searching on this and couldn’t find anything, but apologies anyway if it’s been asked before:

I wanted the “Read more…” link to link to an anchor in the post rather than just the permalink, so the reader could be delivered to the place they stopped reading rather than the top of a new page.

I was able to do this by including <a id="jumphere"></a> after the <!--more--> tag in my post and then using <a href="{{ .RelPermalink }}#jumphere">Read more...</a> in my li.html template.

However, I was wondering if there was an easier way that I had overlooked? If not, I was thinking a feature idea for Hugo may be to insert an anchor automatically when parsing the <!--more--> tag much like heading anchors currently work, and a function to link directly to it.

Thanks
Travis

2 Likes

Is there any progress on this feature request? It’s a very useful feature. I have long posts with long teasers and want to skip teaser when a user clicks the “Read more” link.

Just don’t use automatically generated summaries!

---
summary: short description of the content
---

Main content of your post
<a href="{{ .RelPermalink }}#content">Read more</a>
<article>
<header>…</header>
<main id="content">{{ .Content }}</main>
</article>

Hi nternetinspired,

thank you for your advice, but it doesn’t work in my case. In my blog posts I have really huge summaries with several paragraphs of text, custom short codes, which expanded to photo galleries, youtube videos, etc. I don’t want to fit such a big piece of content into a front matter, this will look ugly. And I believe, front matter is a place for meta data, not for the content itself.

Actually, with a short summary like in your example you even don’t need this feature. In my case, when user clicks a “read more” link he or she should scroll 2-3 screens down to reach a new content, that isn’t a part of summary. I want to avoid this unnecessary scrolling.

Are you certain that that’s what a summary is meant to be?

Are you certain that that’s what a summary is meant to be?

Let’s not call it a summary, let’s call it a teaser. That term might be more appropriate here. And yes, in my case, such big teasers are what I need. The blog post itself can be up to 20-30 screens long, so 2-3 screens of a teaser isn’t as big as it might sound. Here is an example of one of such posts: Путешествие в Исландию | Ромка!eu

Speaking only for me: that long a teaser (or summary of abstract or whatever) would not entice me to read the whole piece. But you know your audience.

1 Like