When create a publishing page in SharePoint 2013, you select the content type/page layout, provide name and url, and then when you create the page, say MyHomePage.aspx, it just redirects to the Page library - AllItems View page. Is it possible to redirect to MyHomePage.aspx in edit mode ?

  • Have you tried setting the source= parameter in the URL to redirect to the current page? sharepoint.stackexchange.com/questions/153673/… Mar 10 '16 at 7:40
  • Hascking the Source parameter was indeed the good approach IMO... but it has to be done right before the form is posted, to change the target URL of the POST and include the desired Source. See my answer.
    – Evariste
    Mar 10 '16 at 13:14
  • Source param will not work. You can't set the parameter to point to a page that hasn't been created yet (unless you know in advance what its URL will be). Mar 10 '16 at 14:50
  • That is correct I was thinking of that option and tried it, and it did'nt work as i don't know the page name in advance. The solution Evariste is perfect. Mar 10 '16 at 18:10

Yes, you can totally do this, but not with the OOB "Add a Page" link. You'll need to provide a direct link to the CreatePage page with the Content Type ID specified via the query string. You also need to have your desired page layout bound to that content type. You can surface the link in a custom Site Action or some other UI action.

The link would look something like this:

window.location = "https://yourtenant.sharepoint.com/sites/yoursite/_layouts/15/CreatePage.aspx?ContentTypeId=0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D007B343FEF28E8BB4AA7E872750679F7A1003F19B3B4862CEE468966162498747811"

I tested this in both SharePoint Online and SP Server 2013. I can't explain why it works this way and not with the OOB method, but it does.

When you request the page like this your correct content type and page layout will be pre-selected. After completing the form you'll get redirected to the new page in edit mode.

Note that the list content type IDs will be different from site to site, so if you plan to deploy this to multiple sites you'll have some additional work to do to fetch that ID.

  • hi Derek, Thanks. Yes this is a great solution without any code. I actually had an html page to do redirect and had links to the html page in promoted list(tiles) and now i changed the url in the redirect html page to just have only ContentTypeID and it works like charm. I wish there was an OOTB option as well. Mar 10 '16 at 18:51

I've just worked out the following script on my SP2010 VM.
Put that JavaScript code at the end of the <head> section of your System (Default) master page (use SharePoint Designer for instance to edit the current Default master page):

<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.12.0.min.js"></script>

<script type="text/javascript">

$( document ).ready(function() {
    var currentAddress = window.location.pathname; 
    if (currentAddress.toLowerCase().indexOf('/createpage.aspx') == -1) // not the creation page page

    $("input[id$='buttonCreatePage']").each(function() {
        // The OK button
        var $OKButton = $(this);

        var previousClickHandler = this.onclick;
        this.onclick = null;

        // New click handler
        $OKButton.click(function() {
            var currentAction = $("form").attr('action');

            var newPageUrl = _spPageContextInfo.webServerRelativeUrl;
                newPageUrl = newPageUrl + "/";
            newPageUrl = newPageUrl + $("[id$='parentUrlLabel']").text();
            newPageUrl = newPageUrl + $("input[id$='urlNameTextBox']").val() + ".aspx?ControlMode=Edit";

            var newAction = UpdateQueryString("Source", newPageUrl , currentAction);
            $("form").attr('action', newAction);


// From http://stackoverflow.com/a/11654596/3439544
function UpdateQueryString(key, value, url) {
    if (!url) url = window.location.href;
    var re = new RegExp("([?&])" + key + "=.*?(&|#|$)(.*)", "gi"),

    if (re.test(url)) {
        if (typeof value !== 'undefined' && value !== null)
            return url.replace(re, '$1' + key + "=" + value + '$2$3');
        else {
            hash = url.split('#');
            url = hash[0].replace(re, '$1$3').replace(/(&|\?)$/, '');
            if (typeof hash[1] !== 'undefined' && hash[1] !== null) 
                url += '#' + hash[1];
            return url;
    else {
        if (typeof value !== 'undefined' && value !== null) {
            var separator = url.indexOf('?') !== -1 ? '&' : '?';
            hash = url.split('#');
            url = hash[0] + separator + key + '=' + value;
            if (typeof hash[1] !== 'undefined' && hash[1] !== null) 
                url += '#' + hash[1];
            return url;
            return url;


You can also use a server-local version of jQuery instead of the "http://ajax.aspnetcdn.com" one; ideally you already load jQuery for other purposes. Or you maybe can rewrite the whole thing without jQuery. I'll test on SP2013 as soon as I open my 2013 VM. But IMO it should work, unless maybe for some element Ids to be changed.

OK, I tested it on SP2013, and it works just fine as well.

  • This rocks! :) Thanke a lot Evariste! it definetely works, I tried in SP2013. Mar 10 '16 at 18:07
  • Also can you help me with this query as well - sharepoint.stackexchange.com/questions/173555/… Mar 10 '16 at 18:07
  • Glad to hear it helped. Please, feel free to mark the answer as accepted if you think it may help others! :)
    – Evariste
    Mar 10 '16 at 18:30
  • Perfect! exactly what i was looking for. Aug 14 '17 at 7:36

This functionality is hard coded into SharePoint, to redirect back to the Library.

As the only "documentation" for this is within SharePoint's own code, there is a large effort needed to provide that documentation.

  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review
    – Waqas Sarwar MVP
    Mar 10 '16 at 2:27
  • 4
    It absolutely does. It's simply not possible. Mar 10 '16 at 2:33
  • As per the Forum's rule, you have to give more details i.e source or supporting documentation. BTW, 3 people review and decide it
    – Waqas Sarwar MVP
    Mar 10 '16 at 2:36
  • 3
    The documentation is in SharePoint's own code, and honestly, it is not worth the effort to decompile to provide that documentation. But feel free to do so if you have the time to spend on it. Mar 10 '16 at 2:37
  • 2
    Trevor's answer is "no it isn't possible". Not sure what more he can do but if you don't think his answer is helpful then feel free to down-vote, but I don't think flag for deletion is necessary or helpful.
    – SPDoctor
    Mar 10 '16 at 9:33

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.