I know that MVC and by definition Sitecore MVC renders components from top to bottom order, but is there any way to force (hack) a controller rendering (which is used in the head of the page) to be rendered after another specific rendering lower down in the page?

I know this kind of makes an implied dependency which is crappy and generally goes against the philosophy of MVC, but I don't see another way around this particular problem. All the markup needs to be in place in the page at the point of page load, so a JavaScript-based solution won't work here, unfortunately.

1 Answer 1


Yep. There are various ways to go about it. Here is one.

@using Sitecore.Mvc
    Layout = null;

    HtmlString main = Html.Sitecore().Placeholder("MAIN");
    HtmlString head = Html.Sitecore().Placeholder("HEAD");
<!DOCTYPE html>

    <title>@Html.Sitecore().Field("title", new { DisableWebEdit = true })</title>

    <h2>Cross component comms layout</h2>


Here, main is rendered before head (which is what you ask for), yet still output in the correct order in the document.


Additional reference:

  • 4
    Dammit! I see a question I could answer and you've already linked to my blog post on the topic! I am too slow for this malarky... ;-)
    – JermDavis
    May 15, 2018 at 14:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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