In SP2013, how can I check if the current page is the default page of the current site using javascript object model or REST api?


  • which template are you using? – Marcelo Espinosa Aug 24 '16 at 22:08
  • both publishing and team site. – omega Aug 24 '16 at 22:09
  • I used a powershell script some time ago, that iterates throug all the Web's RootFolder files, and maybe if you compare the names you can achieve what you need.. I know that's not exactly what you want because you need this to work using the REST api, but maybe you find it useful: $site = Get-SPSite 'yoursite' $web = $site.RootWeb foreach($file in $web.RootFolder.Files){ write-host $file.Name -ForegroundColor Magenta } – Marcelo Espinosa Aug 24 '16 at 23:34

At first get the current page from _spPageContextInfo

var currentPage = _spPageContextInfo.serverRequestPath

Now make a GET request in following end-point to get default or welcome page


After getting the response, check if both are same.

PS: It works in team & publishing site both.

Sample code is jQuery & REST API

SP.SOD.executeFunc("SP.js", "SP.ClientContext", function() {
    var currentPage = _spPageContextInfo.serverRequestPath
        url: _spPageContextInfo.webAbsoluteUrl + "/_api/Web/RootFolder/WelcomePage",
        type: "GET",
        headers: {
            "accept": "application/json;odata=verbose",
        success: function(data) {
            if (currentPage.indexOf(data.d.WelcomePage) > -1) {
                console.log("Current page is default");
            } else {
                console.log("Current page is not default");
        error: function(error) {

SP.SOD.executeFunc is important, you are executing code on publishing site

  • This is for team site? Is there one for publishing site? – omega Aug 25 '16 at 5:40
  • Did you try in publishing site? – Atish Dipongkor - MVP Aug 25 '16 at 5:43
  • It works in team and publishing site both. @omega – Atish Dipongkor - MVP Aug 25 '16 at 6:00
  • Post is a little old, but thought I would comment that if you're working in SPO, there's a _spPageContextInfo.isWebWelcomePage property. Might be worth checking if the latest SP 2013/2016 OnPrem code has it before going REST call. – Jim Barntish Oct 10 '17 at 17:38

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.