How to write elegant conditional bits of markup in Razor views?
If you find a pattern getting too repetitive, you can use @helper instead:

@helper ShowIfNotNull(string header) {
    @if (!string.IsNullOrEmpty(header))
        @:&lt;h2&gt;header&lt;/h2&gt;
    }
}

&lt;h1&gt;@Model.Title&lt;/h1&gt;
@ShowIfNotNull(Model.Subtitle)