Watch video

In this chapter, you will get started with the Razor Syntax. 
You will add some server code, by adding code blocks. You will get familiar with Razor by using conditional logic, through loops. Naturally, for this, you are going to need some programming knowledge.

If your Umbraco site is set up with the MVC rendering engine, your templates are Razor views. 
You can add markup to your templates, but with the Razor Syntax, you will be able to write server code. So, you have already added some server code. If you use the Insert Umbraco Page Field type, it will insert: @Umbraco.Field("bodytext") and property alias.

This is an example of server code by using Razor. ** 
The main thing that you will use Razor for, is to **query Umbraco data
. Query that data, and transform it into the markup you need for your site. You will use it for dynamic elements, like navigation, breadcrumb, new lists of items, site maps and so on. What's good to know, is that this is a .net standard to Razor Syntax. It is not something custom for Umbraco.

*There are plenty of resources available on the net to learn more about Razor Syntax. * 
The two most recommended resources are:

*1. Introduction to ASP.NET Web Programming Using the Razor Syntax *

*2. C# Razor Syntax Quick Reference *

*The main advantages that the Razor Syntax offers you is that it is compact, expressive, fluid and easy to learn. * 
You don't have to write a lot of code. Razor enables fast and fluid coding work, and it is very easy to learn - as you will see in this chapter. It enables you to quickly be productive, with a minimum of concepts.

Let's review this introduction.

  • You will use the Razor Syntax to write server code mainly to query Umbraco data.

Razor Syntax

Total Time: 00:28:02

Introduction to the razor syntax with examples on how to write code blocks, inline expressions, comments, variables, conditional logic, loops,...