Deprecated. This class is deprecated and should not be used in new scripts.
Create and access Google Sites.
Deprecated properties
Property | Type | Description |
---|---|---|
AttachmentType |
| |
PageType |
|
Deprecated methods
Method | Return type | Brief description |
---|---|---|
|
| Creates a new Site by copying an existing Site. |
|
| Creates a new Site. |
|
| Returns the active page, if the script is hosted in a container, or null otherwise. |
|
| Returns the active container, if the script is hosted in a container, or null
otherwise. |
|
| Retrieves first 200 Sites belonging to this domain. |
|
| Retrieves all Sites belonging to this domain. |
|
| Retrieves a Page by url. |
|
| Retrieves a Site for the given Google Site, if the user is a consumer who does not have a hosted domain. |
|
| Retrieves a Site for the given Google Site. |
|
| Retrieves a Site by url. |
|
| Retrieves first page of Sites for a user, if the user is a consumer who does not have a hosted domain. |
|
| Retrieves Sites for a user between the given bounds if the user is a consumer who does not have a hosted domain. |
|
| Retrieves first page of Sites belonging to this user in this domain. |
|
| Retrieves all Sites belonging to this user in this domain for the given range given. |
Deprecated methods
copySite(domain, name, title, summary, site)
copySite(domain, name, title, summary, site)
Deprecated. This function is deprecated and should not be used in new scripts.
Creates a new Site by copying an existing Site.
Warning: Copying a site takes time, from seconds to possibly many minutes, depending on the size of the site. Although the method returns right away, the copy is still going on in the background, and not all pages in the copied site are immediately available. This method can also be used to instantiate a new site based on a given template.
// This creates a site. Note that this only works for Google Workspace domains. // There is no version of this API for consumer accounts. var site = SitesApp.createSite("examplepetstore.com", "homepage", "My Home Page", "This is a new site I created!"); var siteCopy = SitesApp.copySite("examplepetstore.com", "homepage-clone", "Cloned Home Page", "Begun, these clone wars have.", site);
Parameters
Name | Type | Description |
---|---|---|
domain | String | The Google Workspace hosted domain, such as examplepetstore.com. |
name | String | The webspace name found in the URL, such as mySite. |
title | String | The title of the site |
summary | String | The description of the site |
site |
| The Site to copy from. This can either be a site or a template. If the parameter is an existing site then the entire contents of the site will be copied. If the given Site is a template, then a new Site is created based on that template. |
Return
— The site that was copied. Note that the copy is asynchronous, and the copy operation
may still be ongoing even though a reference to the site has been returned.Site
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
createSite(domain, name, title, summary)
createSite(domain, name, title, summary)
Deprecated. This function is deprecated and should not be used in new scripts.
Creates a new Site.
// This creates a site. Note that this only works for Google Workspace domains. // There is no version of this API for consumer accounts. var site = SitesApp.createSite("examplepetstore.com", "homepage", "My Home Page", "This is a new site I created!");
Parameters
Name | Type | Description |
---|---|---|
domain | String | The Google Workspace hosted domain, such as examplepetstore.com. |
name | String | The path name found in the URL, such as mySite. |
title | String | The title of the site. |
summary | String | The description of the site. |
Return
— The created site.Site
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
getActivePage()
getActivePage()
Deprecated. This function is deprecated and should not be used in new scripts.
Returns the active page, if the script is hosted in a container, or null
otherwise.
var site = SitesApp.getActivePage();
Return
— The active container if it is a sites page.Page
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
getActiveSite()
getActiveSite()
Deprecated. This function is deprecated and should not be used in new scripts.
Returns the active container, if the script is hosted in a container, or null
otherwise.
var site = SitesApp.getActiveSite();
Return
— The active container if it is a site.Site
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
getAllSites(domain)
getAllSites(domain)
Deprecated. This function is deprecated and should not be used in new scripts.
Retrieves first 200 Sites belonging to this domain. To get all the sites, use the
method to page through the results.
getAllSites(domain, start, max)
// This writes the first page of sites belonging to a Google Workspace // domain to the log. var sites = SitesApp.getAllSites("examplepetstore.com."); for(var i in sites) { Logger.log(sites[i].getUrl()); }
Parameters
Name | Type | Description |
---|---|---|
domain | String | The Google Workspace hosted domain, such as examplepetstore.com. |
Return
— An array of sites belonging to the domain.Site[]
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
getAllSites(domain, start, max)
getAllSites(domain, start, max)
Deprecated. This function is deprecated and should not be used in new scripts.
Retrieves all Sites belonging to this domain.
// This writes the a list of sites in domain example.com to the log. var pageStart = 0; var pageSize = 50; while (true) { Logger.log("Loading sites starting at %s", pageStart); var sites = SitesApp.getAllSites("examplepetstore.com", pageStart, pageSize); 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()); } }
Parameters
Name | Type | Description |
---|---|---|
domain | String | The Google Workspace hosted domain, such as examplepetstore.com. |
start | Integer | The index of the first site to return. |
max | Integer | The maximum number of results to return. |
Return
— An array of sites belonging to the domain.Site[]
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
getPageByUrl(url)
getPageByUrl(url)
Deprecated. This function is deprecated and should not be used in new scripts.
Retrieves a Page by url.
// This snippet retrieves the page at the given URL. // Returns null if the page does not exist or if the URL given is invalid. var page = SitesApp.getPageByUrl( "https://sites.google.com/site/demositeappsscript/mylistpage"); Logger.log(page.getName());
Parameters
Name | Type | Description |
---|---|---|
url | String | The public url. |
Return
— A Page
instance corresponding to the page at the URL or Pagenull
if the
page does not exist.
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
getSite(name)
getSite(name)
Deprecated. This function is deprecated and should not be used in new scripts.
Retrieves a Site for the given Google Site, if the user is a consumer who does not have a hosted domain.
// Returns a Site instance var site = SitesApp.getSite('mysite');
Parameters
Name | Type | Description |
---|---|---|
name | String | The webspace name found in the URL, such as mySite. |
Return
— A Site instance corresponding to a consumer site.Site
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
getSite(domain, name)
getSite(domain, name)
Deprecated. This function is deprecated and should not be used in new scripts.
Retrieves a Site for the given Google Site.
// Returns a Site instance var site = SitesApp.getSite('example.com', 'mysite');
Parameters
Name | Type | Description |
---|---|---|
domain | String | The Google Workspace hosted domain, such as examplepetstore.com. |
name | String | The webspace name found in the URL, such as mySite. |
Return
— A Site instance corresponding to a hosted domain.Site
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
getSiteByUrl(url)
getSiteByUrl(url)
Deprecated. This function is deprecated and should not be used in new scripts.
Retrieves a Site by url.
// This snippet retrieves the site at the given URL // Throws an Invalid argument exception if the site does not exist or if // the URL given is invalid var site = SitesApp.getSiteByUrl("https://sites.google.com/site/demosite"); Logger.log(site.getName());
Parameters
Name | Type | Description |
---|---|---|
url | String | The public url. |
Return
— A Site found at the given URL.Site
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
getSites()
getSites()
Deprecated. This function is deprecated and should not be used in new scripts.
Retrieves first page of Sites for a user, if the user is a consumer who does not have a hosted domain.
// This writes the first page of sites owned by the user running // the script to the log. var sites = SitesApp.getSites(); for(var i in sites) { Logger.log(sites[i].getUrl()); }
Return
— An array of sites beloning to the user running the script.Site[]
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
getSites(start, max)
getSites(start, max)
Deprecated. This function is deprecated and should not be used in new scripts.
Retrieves Sites for a user between the given bounds if the user is a consumer who does not have a hosted domain.
var sites = SitesApp.getSites(25, 50); for(var i in sites) { Logger.log(sites[i].getUrl()); }
Parameters
Name | Type | Description |
---|---|---|
start | Integer | The index of the first site to return. |
max | Integer | The maximum number of results to return. |
Return
— An array of all the sites owned for a user.Site[]
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
getSites(domain)
getSites(domain)
Deprecated. This function is deprecated and should not be used in new scripts.
Retrieves first page of Sites belonging to this user in this domain.
// This writes the first page of sites owned by the user running // the script to the log. var sites = SitesApp.getSites("example.com"); for(var i in sites) { Logger.log(sites[i].getUrl()); }
Parameters
Name | Type | Description |
---|---|---|
domain | String | The Google Workspace hosted domain, such as examplepetstore.com. |
Return
— An array of sites beloning to the user running the script.Site[]
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
getSites(domain, start, max)
getSites(domain, start, max)
Deprecated. This function is deprecated and should not be used in new scripts.
Retrieves all Sites belonging to this user in this domain for the given range given.
// This writes the a list of sites owned by the user running // the script in positions bounded by the start and max values to the log. var sites = SitesApp.getSites("example.com", 25, 50); for(var i in sites) { Logger.log(sites[i].getUrl()); }
Parameters
Name | Type | Description |
---|---|---|
domain | String | The Google Workspace hosted domain, such as examplepetstore.com. |
start | Integer | The index of the first site to return. |
max | Integer | The maximum number of results to return. |
Return
— An array of sites belonging to the user.Site[]
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds