Articles with images at index.html

Hello,

Is there any way to loop a set of articles in the main page, every one with a custom image defined in each YAML ?

Is there any way or it has to be manually done?

Thank You.

Yes of course. Here is a code snippet from my blog’s index. I’m using partials to keep my ‘index’ page clear:

/ Display multiple Blog posts
#frontblog
  %h1.section 
    Latest articles 
    %p.meta_inline
      %a.title{:href => '/feed-articles.xml'}
        %i.fa.fa-rss
    - blog('articles').articles[0...8].each do |article|
      %h2.post
        %i.fa.fa-pencil
        = link_to article.title, article.url
        %p.meta_inline
          %time= article.date.strftime('%b %Y')
    %p.meta_inline{style: 'margin-left: 5%;'}
      %i.fa.fa-arrow-right
      = link_to 'browse articles archive', '/articles.html'

The rest can be found in the documentation.

Now about implementing custom images per article, there are many ways to do it. The best way IMHO is using pretty URLs.

2 Likes

That helped a lot. Thank you so much.