Archive Pledge Posts (Developer Guide)
This is a developer guide listing the steps to archive the Te Wiki pledge posts to AWS.
Background
After Te Wiki the pledge blog posts are archived from Nationbuilder to AWS.
This has a number of advantages:
- these pledege are now 'done' and are considered 'static' - they will not change again.
- removing the pledge blog posts reduces pressure on Nationbuilder database.
- loading the static HTML pledges from AWS gives vastly better page load speeds.
Developer Archive Steps
#1. Export pledge posts as JSON
We archive the pledge posts as raw JSON in case the posts ever need to be recreated in Nationbuilder or used elsewhere.
- Use the Blog Post Admin Tool to extract the pledge posts as JSON.
- Add the new Te Wiki moment slug to the
Select Blogoptions. You will need to update_z_script_api_blog_posts_admin.js - Select
Do No Additional Processing - Check
Save batches as JSON - Run the export. It will download the pledges in batches of 500.
2. Export pledges as raw HTML
Page loads are much faster if we also archive the raw pledge HTML and then reload it directly into the page (rather than rehydrating each pledge from the JSON on page load).
- Find the existing Te Wiki pledge grid (based on blog posts). For example: https://www.reomaori.co.nz/te-wiki-2026-pledges
- View this page in preview. A few admin only tweaks need to be made:
- Go to
_z_module_pledge_feed_bubble_loop.html - Find
pledge_limitand the original value, and then temporarily set to 500 (batch size). - Find
pledge_offset. It should be set initially to 0. - Load the page in preview, the first 500 posts should be in the HTML. Open dev tools and select the parent div (
pledge-feed-container-masonry) and copy the outerHTML. - Create the first HTML export file in VS code. The format should be:
te-wiki-{YEAR}-pledge-posts-{NNNN}.htmlwhere NNNN is zero prefixed post count at that batch. For example: te-wiki-2026-pledge-posts-0001.htmlte-wiki-2026-pledge-posts-0500.htmlte-wiki-2026-pledge-posts-1500.html- Paste the raw HTML into the batch file.
- Remove the parent
<div class="pledge-feed-container-masonry">and trailing div. - Clean up any spaces in the HTML using VS Code:
- Press ⌘⌥F.
- Enable .* (regex).
- Find: (\r?\n)(?:[ \t]*\r?\n)+
- Replace: $1
- Click Replace All.
- Save the batch of pledges.
- Now do the remaing batches of 500. Increment the
offsetby 500 and reload the preview page. - Once all the batches are saved, restore the original batch and offset values.
3. Upload the JSON and HTML Exports to AWS S3
- Log into AWS S3.
- Navigate to
tetaurawhiri->moments - Create a new
te-wiki-YYYYfolder. - Inside that create a
pledgessubfolder. - Inside that create a
htmlandjsonfolder. - Upload the JSON and HTML files to the respective folders.
- Check the pledge HTML is working over the Cloudfront CDN. The URL of the first batch is (replace YEAR with your year):
https://d1qxvstr5k42x1.cloudfront.net/moments/te-wiki-YEAR/pledges/html/te-wiki-YEAR-pledge-posts-0001.html - For example:
https://d1qxvstr5k42x1.cloudfront.net/moments/te-wiki-2026/pledges/html/te-wiki-2026-pledge-posts-0001.html
4. Switch the Pledge Grid from loading Blog Posts to loading HTML from AWS
- Find the Nationbuilder pledge grid control page. It will be a subpage of the main
te-wiki-YYYY-pledgespage, for examplete_wiki_2026_pledges_pledge_grid. - Note the original tags in case you need to revert. The tags will be something like:
module_pledge_grid,module_pledge_grid:te_wiki_pledges_YYYY,pledge_style:show_action,page_no_robots. - Remove the existing tags (except for
page_no_robots) - Add
module_pledge_grid_aws. This activates the AWS pledge grid. - Add
aws_url_prefix:https://d1qxvstr5k42x1.cloudfront.net/moments/te-wiki-YEAR/pledges/html/te-wiki-YEAR-pledge-posts-. Replace YEAR with the current year, for example:aws_url_prefix:https://d1qxvstr5k42x1.cloudfront.net/moments/te-wiki-2026/pledges/html/te-wiki-2026-pledge-posts- - Add
hide_actions_filterto disable the 2023 action filter (unless required). - Note
pledge_style:show_actionhas no effect on the AWS grid - it is showing the original HTML. - Keep
page_no_robots. - If any further tweaks need to be made, the file is
_z_module_pledge_grid_aws.html
5. Delete the original pledge blog posts from Nationbuilder
- This is done in the Blog Post Admin Tool
- The delete routine has been commented out (as it is destructive) in
_z_script_api_blog_posts_admin.js. Read and uncomment code (around lines 650 and 130). - You will need to also paste in the Nationbuilder API token - get from the control panel (settings -> developer).
- Select the correct
Te Wiki pledgesblog - Run the delete routine.
- Check all posts have been deleted - sometimes Nationbuilder glitches. Run the routine again if there is an error.
- Comment the deletion code out once done.