Scripting the Page Hierarchy

How to create the page hierarchy by script?

WikiPakk shows SharePoint pages in a tree-like manner; pages have a parent-child relationship.

If you create SharePoint modern pages “by script” (for example via PowerShell or Power Automate Flow), you might want to set their hierarchical relationship as well.

This article explains where WikiPakk gets its hierarchy information from, so you can potentially create it in an automated fashion.

Where Does WikiPakk Get Its Hierarchy Information From?

There are two hierarchy sources for WikiPakk:

  1. the Site Pages library
  2. the WikiTraccsPageTree hierarchy list, which is hidden

Hierarchy information from the WikiTraccsPageTree list overrides hierarchy information from the Site Pages library.

Site Pages Library

The first (of two) hierarchy sources for WikiPakk is the Site Pages library. WikiPakk looks for specific columns and - if it finds those - uses hierarchy information it finds there.

Display NameInternal NameTypeNotesSample Value
Confluence: Title (WikiTraccs)WT_In_CfTitleSingle line of textOriginal Confluence page title; WikiPakk does not use this value, unless the SharePoint-native Title field is emptyDemo Page
Confluence: Id (WikiTraccs)WT_In_CfContentIdSingle line of textConfluence page ID118587460
Confluence: Parent Id (WikiTraccs)WT_In_CfParentIdSingle line of textID of parent page (0 for the top-most pages)118587459
Confluence: Sibling Order (WikiTraccs)WT_In_CfSiblingOrderNumberOrder in the page tree, lower numbers come first1
Confluence: Space Key (WikiTraccs)WT_In_CfSpaceKeySingle line of textConfluence space key. A migrated root page must have a value in this field. WikiPakk compares this value with the page file name to help identify page copies. WikiPakk does not use this value to link a page to its parent.SPCKEY
Confluence: Created (WikiTraccs)WT_In_CfCreatedDate and TimeCreation date of the original Confluence page; WikiPakk compares it with the SharePoint Created date to tell original migrated pages from copies. For script-created pages, set this to the same value as the page’s Created date; WikiPakk then always treats the page as an original page, even when the page was published long after it was created2023-05-11T09:30:00Z
WT: Transformation Time (WikiTraccs)WT_Out_CfTransformationTimeDate and TimeDate and time when WikiTraccs migrated the page; also used to tell original migrated pages from copies; leave empty for script-created pages2025-10-04T14:12:00Z

When those columns are present, WikiPakk uses the hierarchy information stored in those columns. Note: The values might be overridden by the second hierarchy source.

When even one of those columns is not present, WikiPakk treats the whole site as not migrated: it ignores the hierarchy information in the Site Pages library for all pages of the site and only uses the second hierarchy source. So keep all columns of this table, even where a single page leaves their values empty.

This page describes which values to fill to build a hierarchy. For the reverse angle (which columns must survive a post-migration cleanup), see Removing WikiTraccs Columns from the Site Pages Library.

Hierarchy List

The second (of two) hierarchy sources for WikiPakk is the WikiTraccsPageTree hierarchy list.

The hierarchy list is created automatically in a SharePoint site when the WikiPakk app is added to the site. Removing the WikiPakk app from a site does not delete the list, so you can re-add the app and hierarchy data will still be there.

Every site WikiPakk has been added to will contain the hierarchy list.

The list is hidden and thus not visible in the Site Contents view. But the list can be accessed by using its URL Lists/WikiTraccsPageTree, for example https://COMPANY.sharepoint.com/sites/SITENAME/Lists/WikiTraccsPageTree.

Display NameInternal NameTypeNotesSample Value
TitleTitleSingle line of textSettings in internal JSON format, e.g. forced alphabetic order for children; leave empty
WtPIdWtPIdNumberItem ID of SharePoint page (ID column in Site Pages library)123
WtPPIdWtPPIdNumberItem ID of parent SharePoint page (0 for root pages) (ID column in Site Pages library)0
WtOWtONumberInternal use; leave empty
WtHWtHNumberInternal hierarchy source; must be 33
WtRWtRSingle line of textRank of items in internal format; leave empty

The list is initially empty. When users move tree nodes around, either in the page tree panel or the WikiPakk page tree editor web part, items will be added or (if already existing) modified.

Hierarchy items in the hierarchy list override hierarchy information from the Site Pages library.

Note: If you screw up the hierarchy, the tree is capable of crazy things, like showing duplicate subtrees. Please take care.

Sample Script

The Wiki Transformation Project library contains a PowerShell script that manipulates the hierarchy both in the Site Pages library and in the hierarchy list: CreateHierarchy.ps1. This can serve as sample.

Last modified August 31, 2026