0

What is the best practice for naming the template fields in Sitecore JSS?

Layout service is not making any changes to the filed names when returning JSON response so it seems quite natural to use camelCase for that although it is in contradiction to PascalCase I saw in all the projects I used to work on so far.

Which convention are you using on your project and why? Are there any implications making one of them a better choice or this is just a preference?

  • Check this one - sitecore.stackexchange.com/questions/25358/…, this may help you – Gaurav Agarwal Sep 24 at 9:43
  • @GauravAgarwal thanks, I saw this post but it does not answer fully my question hence I created a new one :) – 9_9 Sep 24 at 9:53
  • 1
    Your field names are for humans to work with, not for code. You should neither focus on Pascal Case or camelCase, your field names should be natural. – Mark Cassidy Sep 24 at 11:15
  • This is why we have the display name which can be set separately, my question was if there is any difference from the code perspective. – 9_9 Sep 25 at 7:37
3

In vanilla JavaScript, the convention is to use camelCase for field names, and PascalCase for class names.

In React, the convention is to use PascalCase only for component names.

So to answer your question, I'd recommend camelCase for the actual field names, and utilizing display names for the Content Author's readability sake.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.