1

Is there a way to retrieve all the new google sites, including the classic sites? I tried using getAllSites(domain, start, max).

// This writes the a list of sites in domain yourdomain.com to the log.
function getNumberOfSites() {
  var pageStart = 0;
  var pageSize = 50;
  while (true) {
    Logger.log("Loading sites starting at %s", pageStart, pageSize);
    var sites = SitesApp.getAllSites("yourdomain.com", pageStart, pageSize);
    // Logger.log(sites);
    if (sites.length == 0) {
      break;
    }
    Logger.log("Got %s sites back", sites.length);
    pageStart += sites.length;
    for(var i in sites) {
      Logger.log("Found site: %s", sites[i].getUrl());
    }
  }
  
}

But I could only retrieve the classic sites which has a prefix /a/ (eg: https://sites.google.com/a/yourdomain.com/demo/). Is there a way I can retrieve both classic and new google sites (which doesn't have a prefix /a/ eg: https://sites.google.com/yourdomain.com/demo/)?

merilstack
  • 703
  • 9
  • 29

1 Answers1

2

Site Service can only access Classic Google Sites as stated in the official document.

A rebuilt version of Sites was launched on November 22, 2016. Apps Script cannot currently access or modify Sites made with this version, but script can still access classic Sites.


Based on this reference: When will available the API Google Site?

The new version of Google Sites does not offer an API at the moment but Google has announced that API capabilities including Google Apps Script integration will be available.

For more detailed information see Deprecation Timeline - classic Google Sites

Google doesn't offer dates for when features will be available so you won't find one.


Ron M
  • 5,791
  • 1
  • 4
  • 16
  • Is there a way to find all the new google sites and how many of them are currently active atleast from the admin panel? – merilstack Feb 03 '21 at 23:10
  • The nearest suggestion that i could give you is to check [Drive Audit Logs](https://support.google.com/a/answer/4579696?hl=en#zippy=) in the Admin Console->Reports. You can filter your `organization` and the `item type: Google Sites` to show all drive activities done then download the results. However, based on the [data retention time](https://support.google.com/a/answer/7061566) of the Drive Audit Logs, data can be saved for 6 months. – Ron M Feb 04 '21 at 16:18