Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Leon 101 posts 489 karma points
    Mar 05, 2015 @ 18:38

    Home page BlogPostRepository


    I'm using Umbraco 7.2.2

    I have a list of blog posts in a blog post repository that I want to display on the front page. What is the razor syntax to do that?

    I thought one of these three code snippets would work, but not having any joy. Please help:

    var blogPosts = CurrentPage.Site().Children("BlogPostRepository");
    var blogPosts = CurrentPage.Site().Children("BlogPostRepository").Children("BlogPost");
    var blogPosts = CurrentPage.Site().Children("BlogPostRepository")[0].Children("BlogPost");

    Any help would be most welcome.


  • Alex Skrypnyk ( 6061 posts 23313 karma points MVP 6x admin c-trib
    Mar 05, 2015 @ 20:09
    Alex Skrypnyk (

    Hi Leon,

    Try to use Descendants instead of Children, like that :



  • Jan Skovgaard 11264 posts 23592 karma points MVP 9x admin c-trib
    Mar 05, 2015 @ 20:10
    Jan Skovgaard

    Hi Leon

    You can do it like this

        var blogPosts = CurrentPage.Descendants("BlogPost");
       foreach(var blostPost in blogPosts){
           blogPost.Id <br />

    I think you can also benefit from reading this cheat sheet of available methods etc.

    Hope this helps.


  • Dennis Aaen 4492 posts 18198 karma points admin hq c-trib
    Mar 05, 2015 @ 21:29
    Dennis Aaen

    Hi Leon,

    If you are using the query builder in Umbraco 7.2.2 then you can use this Razor to display blogposts on the frontpage. You can find the query builder here.

        var selection = CurrentPage.Site().FirstChild("BlogPostRepository").Children("BlogPost").Where("Visible");
        @foreach(var item in selection){
                <a href="@item.Url">@item.Name</a>

    Hope this helps,


Please Sign in or register to post replies

Write your reply to: