1

I'd like to add <link>s to the <head> of each of my blog post pages pointing to the next and previous blog posts, e.g. <link rel="next" href="/blog/my-article/"/>. This will enable flip ahead browsing.

I could use custom front-matter, setting "previousurl" and "nexturl" for each page, and then use those to set the <link>s in the default layout. However, I don't want to have to maintain these links by hand, and I'm not able to use page variables in the YAML front matter. Is there another way to accomplish this?

2 Answers 2

2

I feel stupid: you can use the page variable, even on the default layout page. So I ended up doing:

<link rel="prev" href="{{ page.next.url }}" /> <link rel="next" href="{{ page.previous.url }}" /> 
Sign up to request clarification or add additional context in comments.

Comments

0

You might be able to do it using Liquid assign variables.

{% assign variable = value %} 

1 Comment

I wasn't able to do it with Liquid variables; it might be possible to do it this way, but I couldn't get it to work.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.