How can I feature my most recent blog post on my homepage?

Hello,

i am setting up my store with Debut theme and i added in homepage the featured blog post to display blog posts grid.

now i would like to add an extra section in homepage where to display “one” specific blog post (picture, title and maybe a snippet of text) i would use to highlight the most recent blog post i have added. is that possible?

thanks

hi @fedepatrizi ,

You will need a new section, which I have custom coded for you!

Do as follows and you will have a new “Featured Post” section for your homepage:

1- Go to Your theme > Actions > Edit code. In the code editor find the Sections folder and click on Add New Section.

2- Name this new file featured-post.liquid

3- In the newly created file there will be some code. Replace the contents of the new file with the following code:


  
  {% assign article = articles[section.settings.article] %}

  {% if article %}

    

  {% endif %}

{% schema %}
{
  "name": {
    "cs": "Příspěvky na blogu",
    "da": "Blogopslag",
    "de": "Blogposts",
    "en": "Blog posts",
    "es": "Entradas del blog",
    "fi": "Blogijulkaisut",
    "fr": "Articles de blog",
    "it": "Articoli del blog",
    "ja": "ブログ記事",
    "ko": "블로그 게시물",
    "nb": "Blogginnlegg",
    "nl": "Blogberichten",
    "pl": "Posty na blogu",
    "pt-BR": "Posts do blog",
    "pt-PT": "Publicações no blogue",
    "sv": "Blogginlägg",
    "th": "โพสต์บล็อก",
    "tr": "Blog gönderileri",
    "vi": "Bài viết blog",
    "zh-CN": "博客文章",
    "zh-TW": "部落格文章"
  },
  "class": "index-section",
  "settings": [
    {
      "id": "article",
      "type": "article",
      "label": {
        "en": "Article",
        "es": "Artículo"
      }
    },
    {
      "type": "checkbox",
      "id": "blog_show_author",
      "label": {
        "cs": "Zobrazit autora",
        "da": "Vis forfatter",
        "de": "Autor anzeigen",
        "en": "Show author",
        "es": "Mostrar autor",
        "fi": "Näytä tekijä",
        "fr": "Afficher l'auteur",
        "it": "Mostra autore",
        "ja": "執筆者を表示する",
        "ko": "작성자 표시",
        "nb": "Vis forfatter",
        "nl": "Auteur weergeven",
        "pl": "Pokaż autora",
        "pt-BR": "Exibir autor",
        "pt-PT": "Mostrar autor",
        "sv": "Visa författare",
        "th": "แสดงผู้เขียน",
        "tr": "Yazarı göster",
        "vi": "Hiển thị tác giả",
        "zh-CN": "显示作者",
        "zh-TW": "顯示作者"
      },
      "default": false
    },
    {
      "type": "checkbox",
      "id": "blog_show_date",
      "label": {
        "cs": "Zobrazit datum",
        "da": "Vis dato",
        "de": "Datum anzeigen",
        "en": "Show date",
        "es": "Mostrar fecha",
        "fi": "Näytä päivämäärä",
        "fr": "Afficher la date",
        "it": "Mostra data",
        "ja": "日付を表示する",
        "ko": "날짜 표시",
        "nb": "Vis dato",
        "nl": "Datum weergeven",
        "pl": "Pokaż datę",
        "pt-BR": "Exibir data",
        "pt-PT": "Mostrar data",
        "sv": "Visa datum",
        "th": "แสดงวันที่",
        "tr": "Tarihi göster",
        "vi": "Hiển thị ngày",
        "zh-CN": "显示日期",
        "zh-TW": "顯示日期"
      },
      "default": true
    }
  ],
  "presets": [
    {
      "name": {
        "en": "Featured post",
        "es": "Entradas Destacada"
      },
      "category": {
        "cs": "Blog",
        "da": "Blog",
        "de": "Blog",
        "en": "Blog",
        "es": "Blog",
        "fi": "Blogi",
        "fr": "Blog",
        "it": "Blog",
        "ja": "ブログ",
        "ko": "블로그",
        "nb": "Blogg",
        "nl": "Blog",
        "pl": "Blog",
        "pt-BR": "Blog",
        "pt-PT": "Blogue",
        "sv": "Blogg",
        "th": "บล็อก",
        "tr": "Blog",
        "vi": "Blog",
        "zh-CN": "博客",
        "zh-TW": "部落格"
      },
      "settings": {}
    }
  ]
}
{% endschema %}

4- Save the file.

Now you will have a new section Featured Post in the customizer where you can select any post and it will be featured on your homepage:

let me know if you have any issues implementing this

2 Likes