Get collection ID from a CMS page

page.getCollectionID()

Get the collection ID from a page generated by a collection.

Syntax

1page.getCollectionID(): Promise<string>

Returns

Promise<string>

A promise that resolves to the ID of the collection that generated the page.

Example

1try {
2 // Get Current Page
3 const currentPage = (await webflow.getCurrentPage()) as Page
4
5 // Get Collection ID if page belongs to a collection
6 const collectionId = await currentPage.getCollectionId()
7 console.log(collectionId)
8} catch (error) {
9 console.error([error.cause.tag, error.message])
10}

Error Handling

If the method fails to find a collection, the method will return an error with the following tag and message.

TagMessage
ResourceMissingMissing ${page.id}

Designer Ability

Designer AbilityLocaleBranchWorkflowSitemode
canReadPageSettingsAnyAnyAnyAny
Built with