Your sites Log in Sign up Menu

Title and Link of most recent blog-post

How would I go about displaying the Title and Link to my most recent blog-post on the Landing page? Thank you


3 years ago, 2 replies   Improve this question

Hello! I assume you've already created a landing page, and want to show the title and link of the most recent blog post alongside. To accomplish this we will insert code into your template which displays the link to your most recent entry. We will then conditionally show it depending on whether or not particular custom metadata is declared in the page.

Add new metadata to your landing page

The first step will be to add this custom metadata to your landing page which will trigger the code to show the link. You can pick whichever metadata suits you, but for the purposes of this answer we'll go with Recent. Add it to your landing page like so:


Recent: yes
Link: /

Rest of your landing page here...

Edit your template's source code

The next step will be to add the code which we will only show when the custom metadata Recent is declared. You'll want to fork an editable version of your template, open up the source code for entry.html and add the following lines in between the {{#entry}} ... {{/entry}} tags:

{{#metadata.recent}}
<p>Recent entry:</p>
{{#recentEntries}}
  {{#first}}
     <p><a href="{{{url}}}">{{title}}</a></p>
  {{/first}}
{{/recentEntries}}
{{/metadata.recent}}

This code basically does the following: if the metadata Recent is set, then show the first most recent entry. If you are editing the Diary template say, I'd recommend inserting it on line 15.

Please let me know if you have any questions about this or anything else.

Answered 3 years ago · Improve this answer

Works like a charm – thanks

Answered 3 years ago · Improve this answer