HOW TO: Add a custom field to blog posts in SharePoint 2013

This blog post is a contribution from David Wilborn, an engineer with the SharePoint Developer Support team.

I recently worked a project where we needed to add a custom field to blog posts and use the new Client Side Rendering in SharePoint 2013 to display the field. My first thought was to create a new custom template to render the entire post item. This would allow us to place the new field wherever we liked. While this may be the logical choice in some cases, it practice it takes a lot of work if you want your blog post to look like the out-of-the-box version. There is a lot of customization and custom logic in the blog post rendering.

A simpler option is to set up your custom field to be rendered along with another field. This allows you to keep the default look of the post without having to replicate all of the existing layout and logic yourself.

Note: Custom Client-Side Rendering scripts can sometimes have issues with the Minimal Download Strategy feature. See the following blog post for more information:

In my example, I will be adding a “Subtitle” field that I want to be displayed above the main blog post Body text. The first step is to add the Subtitle field to the Post list for my blog site. I can do this through the GUI by going to Settings -> Site
Content -> Posts.

In this case I am adding a simple text field named “Subtitle.”  Select the “LIST” tab in the upper right corner, and go to “List Settings” on the ribbon:


Toward the bottom of the page above the “Views” section, click “Create column.” Enter “Subtitle” for the column name. You can leave the remainder of the settings at their defaults, and click “OK.” Be sure to enter some values into the Subtitle fields in your Posts list so that we can see them once we’ve modified the template.

The next step is to add my new field to the current view that displays the blog post. I navigate to the main page of my blog site and edit the page (Page tab, select “Edit Page” from the ribbon). Next, I edit the “Posts” web part:

In the “List Views” section, click “Edit the current view” (underneath “Selected View”):


I select the checkbox for the field I created and click “OK” to add it:


The field is now available to be rendered as part of the current view. Note that this custom view is saved as part of the web part page, and is not saved to the views that are part of the Posts list itself. Next, I create the custom JavaScript file that will render the new field. I’ll be adding the “Subtitle” rendering to the renderer for the post Body, since I am displaying the Subtitle over the body. The first part of the code does the work to associate our custom rendering code with the Body field.

Note the “(function() { …” syntax which causes the JavaScript to be executed immediately. This code creates a template for the Body field when it is displayed in a View form, and associates it with our custom rendering function, named CBody. The template is then registered with the Template Manager. 

(function () {

    var overrideCtx = {};

    overrideCtx.Templates = {};

    overrideCtx.Templates.Fields = {‘Body’:{‘View’:CBody}};        



Next we’ll implement the “CBody” function, which is our custom client-side rendering function. This is simply JavaScript code that outputs the HTML we want displayed when the field is rendered by the web part.

 function CBody(ctx) {

    var ret = “<b>” + ctx.CurrentItem.Subtitle + “</b><hr/>” + ctx.CurrentItem.Body;

    return ret; }

The ctx parameter passed in to our custom function gives us access to the current item and its fields. More on this shortly. You can see that the code renders the Subtitle field in bold, followed by a horizontal rule, and then the Body field.  So our final JavaScript file contains both of these functions: 

(function () {

    var overrideCtx = {};

    overrideCtx.Templates = {};

    overrideCtx.Templates.Fields = {‘Body’:{‘View’: CBody}};



function CBody(ctx) {

    var ret = “<b>” + ctx.CurrentItem.Subtitle + “</b><hr/>” + ctx.CurrentItem.Body;

    return ret;


Save the file as formatblogpost.js in your C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\LAYOUTS directory (or equivalent location in your 15 hive).  

The final step is to tell your Posts web part to use the custom JavaScript code. Edit your blog page, and edit the Posts web part. In the Miscellaneous section at the bottom of the web part, specify “formatblogpost.js” (without the quotes) in the JS Link field:

Save your web part and stop editing the page. Do an IISRESET to ensure that the new template is used. If everything has worked correctly, you should see your custom field rendering in your blog posts:


 Let’s take a closer look at the available fields using the JavaScript debugger:

  • With your blog page loaded in Internet Explorer, press F12 to launch the Developer Tools.
  • Click the Script tab
  • Select your JavaScript file from the list
  • Place a breakpoint in the CBody function by clicking to the left of the first line:


  • Click the “Start Debugging” button
  • Refresh your page 

When you hit the breakpoint, click the “Watch” tab in the right plane. Click on the Click to add… text and type “ctx.CurrentItem” in the line.

Expand the ctx.CurrentItem node by clicking the plus sign to the left:


 You can see the fields that are available to your JavaScript code, including the new “Subtitle” field that we created. Since the displayed field names can vary from the internal names, the JavaScript debugger can be invaluable for debugging any issues you have with Client Side Rendering.

Comments (27)

  1. Anonymous says:


    This worked (of course).  Is there a way to link the jslink to a site somewhere else (Master Page Gallery) as mentioned here?…/js-link-for-sharepoint-2013-web-partsa-quick-functional-primer

    It is not working for me.  I tried different variations of the link and nothing…


    Great Post.  This was a nice end for the today as I was looking for this all day long.

    Thanks, Chris

    (add tag JSLink too pls.)  

    Started here:…/9eae92dd-133c-4335-a87c-16a6992c1ede

  2. Vinod says:


    I am here on finding settings for to hide like Email a Link, comments or like etc., and Three dots for more Options(…) disable and show the links directly. any help would be greatly appreciate.



  3. Isha Kapoor says:


    You can upload your Js file as JavaScript Display Template in Master Page Gallery.  Look at my article below for quick steps……/uploading-javascript-js-files-as-javascript-display-template-in-sharepoint-2013

  4. edison says:

    Hi, thanks for this info. I'm working on customize a SharePoint 2013 blog and one of the customizations is to add a custom field. But after this there's another request, I need to add the same default  funcionality of "Categories". I mean, once the new custom field is added it should be displayed as a list like "Categories" and thus it wil work as a posts  filter. Is it possible to replicate the same behavior for this new custom field ? Thank in advance.

  5. Rizwan says:

    Edit Current doesn't work on Posts.aspx

  6. Mario says:

    Any advise to get this working on Posts.aspx?

  7. PatRick says:

    Thanks for this tutorial. It works for me initially when I go to the blog page.

    But when I click on a blog post to view it and from there I click "Back" in my browser it does not show me the new column. Only by clicking on "Refresh" I get to see it again.

    So why does it not work with the "Back" button coming from a post?

  8. Posts.aspx don't work says:

    the steps dont work for Posts.aspx don’t work any advice ?

  9. Sreeraj says:

    Thanks forgiving a good tutorial. I am new to share point and I am getting an issue after implemented this. I am getting a custom field value as "undefined"

  10. Anonymous says:

    I purchased my Passport 9500ix directly from Es belstaff maple leather c belstaff maple jacket uk ort. I had lost the power cord for my Passport 8500 X50 and so I called in to get a replacement cord. While the attendant was taking my order, I asked her

  11. Anonymous says:

    Windows Vista is much-improved and the early word on W belstaff oasis jacket antique black leather indows 7, Microsoft’s next computer operating system, is encouragi Belstaff Centaur Leather jacket ng. Still, the company faces an uphill battle to get

  12. rahul says:

    Thanks. Worked great with text column. However, It’s not working for custom Person or group column. Getting an error [object Object]. Is there any alternate solution for person or group column? Thanks!

  13. SharePoint Training Institutes in Hyderabad India says:

    Too good piece of information, I had come to know about your site from my friend, and let me tell you, your web-page gives the best and the most interesting information. This is just the kind of information that I had been looking for, I’m already your
    rss reader now and I would regularly watch out for the new post, once again hats off to you! Thanks a lot once again, Regards,
    SharePoint Training Institutes in Hyderabad India

  14. SharePoint Online Training in Hyderabad India says:

    Brilliant piece of information, I had come to know about your web-page from my friend, and let me tell you, your webpage gives the best and the most interesting information. This is just the kind of information that I had been looking for, I’m already
    your rss reader now and I would regularly watch out for the new posts, once again hats off to you! Thanks a million once again, Regards,
    SharePoint Online Training in Hyderabad India

  15. SharePoint Developer Training in Hyderabad India says:

    Excellent piece of information, I had come to know about your website from my friend, and let me tell you, your site gives the best and the most interesting information. This is just the kind of information that I had been looking for, I’m already your
    rss reader now and I would regularly watch out for the new posts, once again hats off to you! Thanks a lot once again, Regards,

    SharePoint Developer Training in Hyderabad India

  16. SharePoint Administration Training in Hyderabad says:

    Wonderful information, I had come to know about your blog from my friend, and let me tell you, your website gives the best and the most interesting information. This is just the kind of information that I had been looking for, I’m already your rss reader
    now and I would regularly watch out for the new posts, once again hats off to you! Thanks a ton once again, Regards,
    SharePoint Administration Training in Hyderabad India

  17. Sophia Smith says:

    I have just signed up for free SharePoint 2013 site with

  18. Anonymous says:

    Order High Quality Custom Silicone Bracelets and Rubber her cheap custom wristbands e,we supply debossed silicone wrist bands,custom debossed silicone wristbands,cheap custom wristbands,debossed wristbands and debossed

  19. Martin Harris says:

    Is there a way for the custom field to replace the Createdby value when the blog entry is displayed?

  20. Carrie Perkins says:

    I have the same question as Martin Harris. I would like to hide the auto-populated "Createdby" value and replace it with a manually entered "Author" name. Is there a way to do this? Thanks for the excellent info.

  21. Arturia says:

    Hi, does anybody have a solution to fields with managed metadata?

    As I have tried your solution to fields such as string, and it works.
    However for a field that is of managed Metadata type when you try to check the box of the relevant field, there will be an error.

    Unable to display this Web Part. To troubleshoot the problem, open this Web page in a Microsoft SharePoint Foundation-compatible HTML editor such as Microsoft SharePoint Designer. If the problem persists, contact your Web server administrator.

    The List and custom columns are all working :/

    Thanks in advance.

  22. Beulah Letitia says:

    William Ray

    Hardy, William Ray "Bill" Dec 23, 1930 Feb 9, 2015 Omaha. Preceded in death by parents, Edward and Donzella. Survived by loving wife Virginia M. of">cheap nike shox 62 years; daughter Debra Ann (Terry) Webber; grandson Dr. Barry (Cara) Webber; great grandchildren, Hallie, Liam, Ethan, Amalie and Hyrum; sisters in law, brother in law,
    nieces, nephews and many friends. Retired from Mutual of Omaha as 2nd VP after 38 years. Lifetime member VFW 181. Member of American Legion Post 1. USN USNR Korean War Veteran. VISITATION Thursday 5 7pm with prayer service 7pm at mortuary. FUNERAL SERVICE
    Friday 10am at St. Leo’s Catholic Church, 1920 N. 102nd St. Entombment Resurrection Mausoleum. Memorials to the family to be decided later. ROEDER MORTUARY 108th St. Chapel 2727 North">cheap nike shox 108th St. Please avoid obscene, vulgar, lewd, racist or sexually">cheap nike shox oriented language.

  23. Kinsey Zelda says:

    Gordon’s New Shoes and the MP’s Expenses Scandal

    I am an MP and as you seem like an understanding chap wondered if you would be kind enough to make the invoice out for about 50 quid more. It’s coming up to Gordon’s Birthday and I thought these would be ideal especially if I could claim back a little
    cheap nike air shox bit extra. If you could keep this between ourselves I would much appreciate it and I’d be quite prepared to send you an extra fiver on top of the price for your trouble. I think they’re
    Gordon’s size. You know what they say, ‘average feet; big mouth; horrific smile.’ or something like that. Anyway thanks again, Old Bean.hello old bean,im santa clause no kidding any chance of a sack full of taxpayers money, must be in the rules somewhere for
    toys for the boysNice to hear from you, old">wholesale nike shoes chap. All one needs to do is claim for lots and lots of useless items that could possibly be associated with the everyday
    running">cheap oakley sunglasses outlet of our constituency and then sell the lot for cash on eBay. It really is a doddle. Good Luck! my dear fellow.

  24. Kinsey Zelda says:

    Homemade Wakeskate

    This can be done using a jigsaw, bandsaw or a router template.

    Once your board has been properly sealed, you are ready to apply the grip and take it out on the water!

    Because there are no bindings to lock your feat into, applying grip to the top side of a wakeskate is an essential part of the board. There are generally two kinds of grip people apply to their wakeskates for traction Grip Tape or Foam and it usually comes
    cheap nike shox down to the feel and preference of the rider.

    Matt from Frenique went with the grip tape (the same stuff used on most">wholesale jordan shoes skateboards) on this build. Grip tape will give the rider a lot of traction, but the abrasive coating requires the use of shoes when riding. It can also cause skin abrasions if you
    fall and scrape the board while riding.

    NOW RIDE! No Instructable on this. just">cheap oakley sunglasses get yourself a boat, some water, your new handmade wakeskate and GIV’R!!

    Bio:Roarockit offers the technology, tools and materials to build custom skateboards and other bent wood projects.

  25. Kinsey Zelda says:

    How to Care for Distressed Leather 6 Steps

    Leather furniture can give a home a warm and comfortable look. Distressed leather is especially appropriate for a lived in, antique or rustic look. Distressed leather is usually aniline dyed, and then artificially aged using various techniques. Naturally occurring
    imperfections in the hides like scarring, fleabites and wrinkles are allowed to show through to add to the rough look. These imperfections would be cut out or hidden in other applications. Keeping distressed leather clean is easy and doesn’t really require
    any special tools or cleansers, although a good quality leather conditioner will keep it soft.

    Mix a small amount of mild detergent and lukewarm water to make a cleaning solution. The mixture should be just a little sudsy. Wet your cloth and squeeze out until moist but not saturated.

    Clean the leather, being careful not to
    cheap bo jackson shoes
    saturate the leather with water. This should">cheap oakley sunglasses outlet">wholesale jordans remove any surface dirt that is present. Over time, marks and stains will become part of the patina.

  26. Richard Griffiths says:

    Hi, Firstly great tutorial, I followed your exmaple and it has worked perfectly! However I have added a new field for a featured image which works fine when creating a feed to my main homepage. What I would like to do is also show this image in the post.
    Following your example I get the word undefined appearing, I was wondering if there was a different way to display an image?

  27. spevilgenius says:

    Great Stuff. My only issue is that if I do this with custom columns that I have added to the view, it will not be rendered at all so I can’t override it. I see the field in the CTX object, but in my Fields array, I am not able to add any custom fields so they can’t be overridden using JSLink only. So, it appears that you must modify the view in SP Designer but that does not seem to work on the default.aspx page of the blog site. Any thoughts