A Page on a Google Site.
Methods
Method | Return type | Brief description |
---|---|---|
addColumn(name) | Column | Add a new column to the list. |
addHostedAttachment(blob) | Attachment | Add an attachment to the page. |
addHostedAttachment(blob, description) | Attachment | Add an attachment to the page. |
addListItem(values) | ListItem | Add a list item to the list. |
addWebAttachment(title, description, url) | Attachment | Add a web attachment to the page. |
createAnnouncement(title, html) | Page | Create an announcements for this page. |
createAnnouncement(title, html, asDraft) | Page | Create an announcements for this page. |
createAnnouncementsPage(title, name, html) | Page | Create a new announcements page. |
createFileCabinetPage(title, name, html) | Page | Create a new file-cabinet page. |
createListPage(title, name, html, columnNames) | Page | Create a new list page. |
createPageFromTemplate(title, name, template) | Page | Create a new page from a template. |
createWebPage(title, name, html) | Page | Create a new web page. |
deletePage() | void | Deletes this page. |
getAllDescendants() | Page[] | Gets an array of descendant pages (direct and indirect), up to a limit of 200 pages. |
getAllDescendants(options) | Page[] | Gets an array of descendant pages, with optional advanced arguments. |
getAnnouncements() | Page[] | Get the announcements for this page. |
getAnnouncements(optOptions) | Page[] | Get the announcements for this page. |
getAttachments() | Attachment[] | Get the attachments for this page. |
getAttachments(optOptions) | Attachment[] | Get the attachments for this page. |
getAuthors() | String[] | Get the emails of the authors of the page |
getChildByName(name) | Page | Gets a particular child page. |
getChildren() | Page[] | Gets an array of child pages, up to a limit of 200 pages. |
getChildren(options) | Page[] | Gets an array of child pages, with optional advanced arguments. |
getColumns() | Column[] | Get the columns for the list. |
getDatePublished() | Date | Return the date this page was first published. |
getHtmlContent() | String | Get the HTML content of the page. |
getIsDraft() | Boolean | Returns whether the page is in draft mode. |
getLastEdited() | Date | Return the last edit date, which includes only content edits. |
getLastUpdated() | Date | Return the last updated date, which includes non-content changes like moving. |
getListItems() | ListItem[] | Get the list items for the list. |
getListItems(optOptions) | ListItem[] | Get the list items for the list. |
getName() | String | Return the page's name. |
getPageType() | PageType | Return the type of this page as a SitesApp.PageType enum. |
getParent() | Page | Return the parent of this page. |
getTextContent() | String | Returns the plain-text page content. |
getTitle() | String | Return the page's title. |
getUrl() | String | Get the url of the page. |
isDeleted() | Boolean | Returns whether a page has been deleted. |
isTemplate() | Boolean | Returns whether this page is a copyable template. |
publishAsTemplate(name) | Page | Publish this page as a copyable template. |
search(query) | Page[] | Gets an array of descendant pages that match a search query, up to a limit of 200 pages. |
search(query, options) | Page[] | Gets an array of descendant pages that match a search query, with optional advanced arguments. |
setHtmlContent(html) | Page | Set the HTML content of the page. |
setIsDraft(draft) | Page | Sets whether the page is in draft mode. |
setName(name) | Page | Set this page's name. |
setParent(parent) | Page | Set the parent of this page. |
setTitle(title) | Page | Set the page's title. |
Detailed documentation
addColumn(name)
Add a new column to the list. Only valid for list pages.
var site = SitesApp.getSite("example.com", "mysite"); var page = site.getChildByName("listpage"); // Only valid on List pages. Check for the type like so: // if(page.getPageType() == SitesApp.PageType.LIST_PAGE)) var columns = page.addColumn("new-column");
Parameters
Name | Type | Description |
---|---|---|
name | String | the new column's name |
Return
Column
— the newly created column
Throws
Error
— for pages that aren't list pages
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
addHostedAttachment(blob)
Add an attachment to the page.
var site = SitesApp.getSite("example.com", "mysite"); var page = site.getChildren()[0]; // Create a new blob and attach it. Many useful functions also return // blobs file uploads, URLFetch var blob = Utilities.newBlob("Here is some data", "text/plain", "data.txt"); // Note that the filename must be unique or this call will fail page.addHostedAttachment(blob);
Parameters
Name | Type | Description |
---|---|---|
blob | BlobSource | the data for the attachment |
Return
Attachment
— the newly created attachment
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
addHostedAttachment(blob, description)
Add an attachment to the page. This version of the function allows for a description.
var site = SitesApp.getSite("example.com", "mysite"); var page = site.getChildren()[0]; // Create a new blob and attach it. Many useful: functions also return // blobs file uploads, URLFetch var blob = Utilities.newBlob("Here is some data", "text/plain", "data.txt"); // Note that the filename must be unique or this call will fail page.addHostedAttachment(blob, "Some newly created data");
Parameters
Name | Type | Description |
---|---|---|
blob | BlobSource | the data for the attachment |
description | String | a description of the attachment |
Return
Attachment
— the newly created attachment
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
addListItem(values)
Add a list item to the list. Only valid for list pages.
var site = SitesApp.getSite("example.com", "mysite"); var page = site.getChildByName("listpage"); // Only valid on List pages. Check for the type like so: // if(page.getPageType() == SitesApp.PageType.LIST_PAGE)) // Returns only one item page.addListItem([ "John", "Smith", "123 Main St"]);
Parameters
Name | Type | Description |
---|---|---|
values | String[] | the values for each column |
Return
ListItem
— the newly created ListItem
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
addWebAttachment(title, description, url)
Add a web attachment to the page. Only valid for file cabinet pages.
Web attachments are links - they are not actually hosted by Google Sites.
var site = SitesApp.getSite("example.com", "mysite"); // fetch the child - this must be a File Cabinet page // to programmatically check this, do a comparison: // if(page.getPageType() == SitesApp.PageType.FILE_CABINET_PAGE) var page = site.getChildByName("files"); page.addWebAttachment("Google Robots file", "This is Google's robots.txt file", "http://www.google.com/robots.txt");
Parameters
Name | Type | Description |
---|---|---|
title | String | the title of the attachment |
description | String | a description of the attachment |
url | String | the url of the file being attached |
Return
Attachment
— the newly created attachment
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
createAnnouncement(title, html)
Create an announcements for this page. Only valid for announcement pages.
var site = SitesApp.getSite("example.com", "mysite"); // This snippet will only work with announcement pages - this is different // from a page that is an annoucement (individual announcements). To check // if this method can be called: // if(page.getPageType() == SitesApp.PageType.ANNOUNCEMENTS_PAGE)) var page = site.getChildByName("news"); page.createAnnouncement("Breaking news!", "<h1>Apps Script rocks!</h1>");
Parameters
Name | Type | Description |
---|---|---|
title | String | the page title |
html | String | the page content |
Return
Page
— the newly created Announcements
Throws
Error
— for pages that aren't announcement pages
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
createAnnouncement(title, html, asDraft)
Create an announcements for this page. Only valid for announcement pages.
var site = SitesApp.getSite("example.com", "mysite"); // This snippet will only work with announcement pages - this is different // from a page that is an annoucement (individual announcements). To check // if this method can be called: // if(page.getPageType() == SitesApp.PageType.ANNOUNCEMENTS_PAGE)) var page = site.getChildByName("news"); page.createAnnouncement("Breaking news!", "<h1>Apps Script rocks!</h1>", true);
Parameters
Name | Type | Description |
---|---|---|
title | String | the page title |
html | String | the page content |
asDraft | Boolean | whether to make the announcement a draft |
Return
Page
— the newly created Announcements
Throws
Error
— for pages that aren't announcement pages
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
createAnnouncementsPage(title, name, html)
Create a new announcements page. Note that a parent site or page cannot have more than 500 child pages.
// This method can be called from both a Site instance // as well as a Page instance var site = SitesApp.getSite("example.com", "mysite"); var page = site.getChildren()[0]; site.createAnnouncementsPage("New Announcement", "new-announcement", "<h1>Your announcement goes here</h1>"); page.createAnnouncementsPage("New Announcement", "new-announcement-child", "<h1>Your announcement goes here</h1>");
Parameters
Name | Type | Description |
---|---|---|
title | String | the page title |
name | String | the page name |
html | String | the page content |
Return
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
createFileCabinetPage(title, name, html)
Create a new file-cabinet page. Note that a parent site or page cannot have more than 500 child pages.
// This method can be called from either a site or a page. var site = SitesApp.getSite("example.com", "mysite"); var page = site.getChildren()[0]; site.createFileCabinetPage("New File Cabinet", "new-file-cabinet", "<h1>Your HTML here</h1>"); page.createFileCabinetPage("New File Cabinet", "new-file-cabinet-child", "<h1>Your HTML here</h1>");
Parameters
Name | Type | Description |
---|---|---|
title | String | the page title |
name | String | the page name |
html | String | the page content |
Return
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
createListPage(title, name, html, columnNames)
Create a new list page. Note that a parent site or page cannot have more than 500 child pages.
// This method can be called from either a site or a page. var site = SitesApp.getSite("example.com", "mysite"); var page = site.getChildren()[0]; site.createListPage("New List Page", "new-list-page", "<h1>Your List Page HTML here</h1>", [ "col1", "col2" ]); page.createListPage("New List Page", "new-list-page-child", "<h1>Your List Page HTML here</h1>", [ "col1", "col2" ]);
Parameters
Name | Type | Description |
---|---|---|
title | String | the page title |
name | String | the page name |
html | String | the page content |
columnNames | String[] | the column names used for the list |
Return
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
createPageFromTemplate(title, name, template)
Create a new page from a template. Note that a parent site or page cannot have more than 500 child pages.
// This method can be called from either a site or a page. var site = SitesApp.getSite("example.com", "mysite"); var template = site.getTemplates()[0]; // If an invalid template is passed, this will throw an "Invalid Argument" error. site.createPageFromTemplate("ClonedPage", "cloned-page", template);
Parameters
Name | Type | Description |
---|---|---|
title | String | the page title |
name | String | the page name |
template | Page | the template page |
Return
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
createWebPage(title, name, html)
Create a new web page. Note that a parent site or page cannot have more than 500 child pages.
// This method can be called from either a site or a page. var site = SitesApp.getSite("example.com", "mysite"); var page = site.getChildren()[0]; site.createAnnouncementsPage("New Announcement", "new-announcement", "<h1>Your announcement goes here</h1>"); page.createAnnouncementsPage("New Announcement", "new-announcement-child", "<h1>Your announcement goes here</h1>");
Parameters
Name | Type | Description |
---|---|---|
title | String | the page title |
name | String | the page name |
html | String | the page content |
Return
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
deletePage()
Deletes this page.
var site = SitesApp.getSite("example.com", "mysite"); // Delete ALL the pages! var pages = site.getAllDescendants(); for(var i in pages) { pages[i].deletePage(); }
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
getAllDescendants()
Gets an array of descendant pages (direct and indirect), up to a limit of 200 pages.
var site = SitesApp.getSite("example.com", "mysite"); var pages = site.getAllDescendants();
Return
Page[]
— an array of direct and indirect child pages
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
getAllDescendants(options)
Gets an array of descendant pages, with optional advanced arguments.
var site = SitesApp.getSite("example.com", "mysite"); var descendants = site.getAllDescendants({ type: SitesApp.PageType.WEB_PAGE, start: 0, max: 25, includeDrafts: false, includeDeleted: true, search: "target" }); for(var i in descendants) { Logger.log(descendants[i].getName()); }
Parameters
Name | Type | Description |
---|---|---|
options | Object | JavaScript object fields defined in the Advanced Arguments section below |
Advanced parameters
Name | Type | Description |
---|---|---|
type | PageType[] | only get pages of this type |
start | Integer | start the results here |
max | Integer | the max number of results (default 200) |
includeDrafts | Boolean | whether to include draft pages (default false) |
includeDeleted | Boolean | whether to include deleted pages (default false) |
search | String | only return pages matching this query |
Return
Page[]
— an array of direct and indirect child pages of the given type
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
getAnnouncements()
Get the announcements for this page. Only valid for announcement pages.
var site = SitesApp.getSite("example.com", "mysite"); // This snippet will only work with announcement pages - this is different // from a page that is an annoucement (individual announcements). To check // if this method can be called: // if(page.getPageType() == SitesApp.PageType.ANNOUNCEMENTS_PAGE)) var page = site.getChildByName("news"); var announcements = page.getAnnouncements(); for(var i in announcements) { Logger.log(announcements[i].getHtmlContent()); }
Return
Page[]
— an array of Announcements
Throws
Error
— for pages that aren't announcement pages
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
getAnnouncements(optOptions)
Get the announcements for this page. Only valid for announcement pages.
var site = SitesApp.getSite("example.com", "mysite"); // This snippet will only work with announcement pages - this is different // from a page that is an annoucement (individual announcements). To check // if this method can be called: // if(page.getPageType() == SitesApp.PageType.ANNOUNCEMENTS_PAGE)) var page = site.getChildByName("news"); var announcements = page.getAnnouncements({ start: 0, max: 20, includeDrafts: false, includeDeleted: false, search: "Breaking" }); for(var i in announcements) { Logger.log(announcements[i].getHtmlContent()); }
Parameters
Name | Type | Description |
---|---|---|
optOptions | Object | A JavaScript object containing advanced parameters |
Advanced parameters
Name | Type | Description |
---|---|---|
start | Integer | the start index for the results |
max | Integer | the max number of results to return, which defaults to and may not be more than 200 |
includeDrafts | Boolean | whether to include draft pages (default false) |
includeDeleted | Boolean | whether to include deleted pages (default false) |
search | String | only return pages matching this query |
Return
Page[]
— an array of Announcements
Throws
Error
— for pages that aren't announcement pages
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
getAttachments()
Get the attachments for this page.
var site = SitesApp.getSite("example.com", "mysite"); var page = site.getChildren()[0]; var attachments = page.getAttachments(); for(var i in attachments) { Logger.log(attachments[i].getTitle()); }
Return
Attachment[]
— an array of Attachments
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
getAttachments(optOptions)
Get the attachments for this page.
var site = SitesApp.getSite("example.com", "mysite"); var page = site.getChildren()[0]; // This returns only one attachment var attachments = page.getAttachments({ start: 0, max: 1}); for(var i in attachments) { Logger.log(attachments[i].getTitle()); }
Parameters
Name | Type | Description |
---|---|---|
optOptions | Object | a JavaScript object containing optional parameters |
Advanced parameters
Name | Type | Description |
---|---|---|
start | Integer | the first index to start returning attachments |
max | Integer | the max number of results to return, which defaults to and may not be more than 200 |
Return
Attachment[]
— an array of Attachments
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
getAuthors()
Get the emails of the authors of the page
var site = SitesApp.getSite("example.com", "mysite"); var page = site.getChildren()[0]; var authors = page.getAuthors(); for(var i in authors) { Logger.log(authors[i]); }
Return
String[]
— an array of author email addresses
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
getChildByName(name)
Gets a particular child page.
var site = SitesApp.getSite("example.com", "mysite"); var pages = site.getChildByName("childPage");
Parameters
Name | Type | Description |
---|---|---|
name | String | the child page name |
Return
Page
— the child page
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
getChildren()
Gets an array of child pages, up to a limit of 200 pages.
var site = SitesApp.getSite("example.com", "mysite"); var pages = site.getChildren();
Return
Page[]
— an array of direct child pages
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
getChildren(options)
Gets an array of child pages, with optional advanced arguments.
var site = SitesApp.getSite("example.com", "mysite"); var childPages = site.getChildren({ type: SitesApp.PageType.WEB_PAGE, start: 0, max: 25, includeDrafts: false, includeDeleted: true, search: "target" }); for(var i in childPages) { Logger.log(childPages[i].getName()); }
Parameters
Name | Type | Description |
---|---|---|
options | Object | JavaScript object fields defined in the Advanced Arguments section below |
Advanced parameters
Name | Type | Description |
---|---|---|
type | PageType[] | only get pages of this type |
start | Integer | start the results here |
max | Integer | the max number of results (default 200) |
includeDrafts | Boolean | whether to include draft pages (default false) |
includeDeleted | Boolean | whether to include deleted pages (default false) |
search | String | only return pages matching this query |
Return
Page[]
— an array of direct child pages of the given type
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
getColumns()
Get the columns for the list. Only valid for list pages.
var site = SitesApp.getSite("example.com", "mysite"); var page = site.getChildByName("listpage"); // Only valid on List pages. Check for the type like so: // if(page.getPageType() == SitesApp.PageType.LIST_PAGE)) var columns = page.getColumns(); for(var i in columns) { Logger.log(columns[i].getName()); }
Return
Column[]
— an array of Column
instances
Throws
Error
— for pages that aren't list pages
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
getDatePublished()
Return the date this page was first published.
var site = SitesApp.getSite("example.com", "mysite"); var page = site.getChildren()[0]; Logger.log(page.getName() + " was published " + page.getDatePublished());
Return
Date
— the date of original publication
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
getHtmlContent()
Get the HTML content of the page.
var site = SitesApp.getSite("example.com", "mysite"); var page = site.getChildren()[0]; Logger.log(page.getHtmlContent());
Return
String
— the html content
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
getIsDraft()
Returns whether the page is in draft mode. Only valid for announcements.
var site = SitesApp.getSite("example.com", "mysite"); var page = site.getChildren()[0]; Logger.log("Is this Announcement Page a draft?", page.getIsDraft());
Return
Boolean
— whether the page is in draft mode
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
getLastEdited()
Return the last edit date, which includes only content edits.
var site = SitesApp.getSite("example.com", "mysite"); var page = site.getChildren()[0]; Logger.log(page.getName() + " was last updated " + page.getLastEdited());
Return
Date
— the date the page was last updated, including only content edits
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
getLastUpdated()
Return the last updated date, which includes non-content changes like moving.
var site = SitesApp.getSite("example.com", "mysite"); var page = site.getChildren()[0]; Logger.log(page.getName() + " was last updated " + page.getLastUpdated());
Return
Date
— the date the page was last updated with non-content changes
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
getListItems()
Get the list items for the list. Only valid for list pages.
var site = SitesApp.getSite("example.com", "mysite"); var page = site.getChildByName("listpage"); // Only valid on List pages. Check for the type like so: // if(page.getPageType() == SitesApp.PageType.LIST_PAGE)) var items = page.getListItems(); for(var i in items) { Logger.log(items[i].getValueByName("Status")); }
Return
ListItem[]
— an array of ListItem
instances
Throws
Error
— for pages that aren't list pages
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
getListItems(optOptions)
Get the list items for the list. Only valid for list pages.
var site = SitesApp.getSite("example.com", "mysite"); var page = site.getChildByName("listpage"); // Only valid on List pages. Check for the type like so: // if(page.getPageType() == SitesApp.PageType.LIST_PAGE)) // Returns only one item var items = page.getListItems({ start:0, max: 1 }); for(var i in items) { Logger.log(items[i].getValueByName("Status")); }
Parameters
Name | Type | Description |
---|---|---|
optOptions | Object | A JavaScript object of optional parameters |
Advanced parameters
Name | Type | Description |
---|---|---|
start | Integer | the first index to start iterating from |
max | Integer | the max number of results to return, which defaults to and may not be more than 200 |
Return
ListItem[]
— an array of ListItem
instances
Throws
Error
— for pages that aren't list pages
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
getName()
Return the page's name.
var site = SitesApp.getSite("example.com", "mysite"); var page = site.getChildren()[0]; Logger.log(page.getName());
Return
String
— the name of this page
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
getPageType()
Return the type of this page as a SitesApp.PageType enum.
var site = SitesApp.getSite("example.com", "mysite"); var page = site.getChildren()[0]; var pageType = page.getPageType(); if(pageType == SitesApp.PageType.WEB_PAGE) { Logger.log(page.getName() + " is a Web Page"); }
Return
PageType
— a PageType enum telling whether this is a Web, List, Announcement or File Cabinet Page
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
getParent()
Return the parent of this page.
var site = SitesApp.getSite("example.com", "mysite"); var page = site.getChildren()[0]; Logger.log(page.getName() + " parent: " + page.getParent().getName());
Return
Page
— the parent page of this page
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
getTextContent()
Returns the plain-text page content.
var site = SitesApp.getSite("example.com", "mysite"); var page = site.getChildren()[0]; Logger.log(page.getName() + " content: " + page.getTextContent());
Return
String
— the plain-text content of the page
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
getTitle()
Return the page's title.
var site = SitesApp.getSite("example.com", "mysite"); var page = site.getChildren()[0]; Logger.log(page.getTitle());
Return
String
— the title of this page
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
getUrl()
Get the url of the page.
var site = SitesApp.getSite("example.com", "mysite"); var page = site.getChildren()[0]; Logger.log(page.getUrl());
Return
String
— the url of the page
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
isDeleted()
Returns whether a page has been deleted.
Return
Boolean
— whether the page has been deleted
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
isTemplate()
Returns whether this page is a copyable template.
var site = SitesApp.getSite("example.com", "mysite"); var firstTemplate = site.getTemplates()[0]; if(firstTemplate.isTemplate()) { Logger.log("This will always return true"); }
Return
Boolean
— whether this page is a template
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
publishAsTemplate(name)
Publish this page as a copyable template.
var site = SitesApp.getSite("example.com", "mysite"); var page = site.getChildren()[0]; // Turn this page into a publishable template page.publishedAsTemplate("template-name");
Parameters
Name | Type | Description |
---|---|---|
name | String | The name of the new template |
Return
Page
— the newly published template
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
search(query)
Gets an array of descendant pages that match a search query, up to a limit of 200 pages.
var site = SitesApp.getSite("example.com", "mysite"); var matches = site.search("targetText"); for(var i in matches) { Logger.log(matches[i].getName()); }
Parameters
Name | Type | Description |
---|---|---|
query | String | the full text search query to match |
Return
Page[]
— an array of direct and indirect child pages of the given type
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
search(query, options)
Gets an array of descendant pages that match a search query, with optional advanced arguments.
var site = SitesApp.getSite("example.com", "mysite"); var childPages = site.getChildren({ type: SitesApp.PageType.WEB_PAGE, start: 0, max: 25, includeDrafts: false, includeDeleted: true, search: "target" }); for(var i in childPages) { Logger.log(childPages[i].getName()); }
Parameters
Name | Type | Description |
---|---|---|
query | String | the full text search query to match |
options | Object | JavaScript object fields defined in the Advanced Arguments section below |
Advanced parameters
Name | Type | Description |
---|---|---|
type | PageType[] | only get pages of this type |
start | Integer | start the results here |
max | Integer | the max number of results (default 200) |
includeDrafts | Boolean | whether to include draft pages (default false) |
includeDeleted | Boolean | whether to include deleted pages (default false) |
Return
Page[]
— an array of direct and indirect child pages of the given type
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
setHtmlContent(html)
Set the HTML content of the page.
var site = SitesApp.getSite("example.com", "mysite"); var page = site.getChildren()[0]; page.setHtmlContent("<h1>New Page Content</h1>");
Parameters
Name | Type | Description |
---|---|---|
html | String | the new content |
Return
Page
— this Page for chaining
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
setIsDraft(draft)
Sets whether the page is in draft mode. Only valid for announcements.
var site = SitesApp.getSite("example.com", "mysite"); var page = site.getChildren()[0]; // Take the page out of draft mode page.setIsDraft(false);
Parameters
Name | Type | Description |
---|---|---|
draft | Boolean | the new status |
Return
Page
— this Page for chaining
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
setName(name)
Set this page's name.
var site = SitesApp.getSite("example.com", "mysite"); var page = site.getChildren()[0]; page.setName("new-name");
Parameters
Name | Type | Description |
---|---|---|
name | String | the new name |
Return
Page
— this Page for chaining
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
setParent(parent)
Set the parent of this page.
var site = SitesApp.getSite("example.com", "mysite"); var child = site.getChildByName("childToBeMoved"); var parent = site.getChildByName("newParent"); child.setParent(parent);
Parameters
Name | Type | Description |
---|---|---|
parent | Page | the new parent |
Return
Page
— this Page for chaining
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds
setTitle(title)
Set the page's title.
var site = SitesApp.getSite("example.com", "mysite"); var page = site.getChildren()[0]; page.setTitle("New Title");
Parameters
Name | Type | Description |
---|---|---|
title | String | the new title |
Return
Page
— this Page for chaining
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://sites.google.com/feeds