Steps for Generating Individual Editions with a PowerShell Script

Whenever a new release of TiddlyWiki comes out, I used to manually update each individual TW file (my editions), which was tedious and involved managing plugins, configurations, and other details. Below is a PowerShell script (PowerShell works on all major operating systems) that helps create new editions on the fly. Here are the steps:

  1. I have TiddlyWiki running on Node.js on Windows 11.
  2. I maintain an Editions folder containing customized TiddlyWiki folders (with plugins, themes, languages, and pre-configured settings) like Mehregan, Tirgan, XP, Krystal, Notebook, etc.
  3. I use TiddlyWiki on Node.js to generate index.html for each edition (e.g., single-file TiddlyWiki).
  4. I store them in two global folders, one on a thumb drive and another on the computer drive.
  5. I use a small PowerShell script to quickly create copies of any version wherever needed.

Below is the PowerShell script to create single-file editions in both compressed and normal sizes.

<#
.SYNOPSIS
    Builds standalone (single .html) TiddlyWiki editions.

.DESCRIPTION
    This script generates both normal and minified (.html) versions of multiple
    customized TiddlyWiki editions stored in:
        D:/TiddlyWiki/Editions

    The output files are built in:
        D:/TiddlyWiki/S-Editions

    After building, each edition folder is mirrored to:
        C:/TW/000. Empty/S-Editions/<version>
        G:/TW/000. Empty/S-Editions/<version>

    Editions and their subfolders are defined in the `$editions` array
    inside the script — making it easy to add, remove, or rename editions.

.EXAMPLE
    tw-make-single-editions

    Builds all editions listed in `$editions` (normal + minified) and copies them
    to the target folders on C: and G: drives.

.NOTES
    Author: Mohammad Rahmani

    Revision History:
      1.0  - 2022-12-12 : Initial release
      1.1  - 2022-12-25 : General improvements
      1.2  - 2022-12-28 : Remove Uglify plugin after compression
      1.3  - 2023-04-21 : Script moved to C:/MyScripts; restore path after run
      1.4  - 2025-07-05 : Added 'Course' edition
      2.0  - 2025-08-12 : Refactored with arrays & loops for easier maintenance (with the help of GPT-5)

#>


Clear-Host
Write-Host "`nStart making TiddlyWiki single file editions`n"

$startTime = Get-Date
Write-Host "The script was started at $startTime"

# Paths
$currentPath  = Get-Location
$editionPath  = "D:\TiddlyWiki\Editions"
$buildPath    = "D:\TiddlyWiki\S-Editions"

# List of editions and their subfolders (empty string means the root edition)
$editions = @(
    @{ Name = "Vanilla TiddlyWiki";   Paths = @("vanilla", "vanilla/minified") },
    @{ Name = "Basic TiddlyWiki";     Paths = @("basic", "basic/minified") },
    @{ Name = "Mehregan (Zettelkasten)"; Paths = @("mehregan", "mehregan/minified") },
    @{ Name = "Tirgan (Scientific)";  Paths = @("tirgan", "tirgan/minified", "tirgan/course") },
    @{ Name = "Notebook TiddlyWiki";  Paths = @("notebook", "notebook/minified") },
    @{ Name = "TiddlyWiki xp";        Paths = @("xp", "xp/minified") },
    @{ Name = "TiddlyWiki Krystal";   Paths = @("krystal", "krystal/minified") }
)

# Change to S-Editions build folder
Set-Location -Path $buildPath

# Build all editions
foreach ($edition in $editions) {
    Write-Host "`n--- Making $($edition.Name)" -ForegroundColor Yellow
    foreach ($path in $edition.Paths) {
        tiddlywiki "$editionPath/$path" --build index
    }
}

# Version and paths
$version = tiddlywiki --version
$targetPaths = @(
    "C:\TW\000. Empty\S-Editions\$version",
    "G:\TW\000. Empty\S-Editions\$version"
)

# Delete target folders if they exist
foreach ($target in $targetPaths) {
    Remove-Item -Force -Recurse $target -ErrorAction Ignore
}

# Copy new builds to targets
foreach ($target in $targetPaths) {
    robocopy "$buildPath\$version" $target /MIR
}

# Return to original path
Set-Location -Path $currentPath

# Timing info
$endTime      = Get-Date
$timeElapsedS = ($endTime - $startTime).TotalSeconds

Write-Host "`nThe script finished at $endTime."
Write-Host "Elapsed time in seconds: $timeElapsedS`n" -ForegroundColor Cyan








Further Information:
All edition comes int two sizes: minified (using the great Uglify plugin from @Flibbles) and un-minified. The folder structure is like below

image

And this is a sample tiddlywiki.info (here for Notebook edition)

{
    "description": "Notebook single edition",
    "plugins": [
        "tiddlywiki/tiddlyweb",
        "tiddlywiki/filesystem",
        "tiddlywiki/highlight",
		
        "flibbles/relink",
        "flibbles/relink-titles",		
        "wikilabs/link-to-tabs",
        "evidentlycube/autocomplete",
		
		"kookma/favorites",
		"kookma/shiraz",
		"kookma/shiraz-callout",		
		"kookma/trashbin",
		"kookma/tweaks"		
    ],
    "themes": [
        "tiddlywiki/vanilla",
        "tiddlywiki/snowwhite"
    ],
     "build": {
        "index": [
			"--commands","[[--output]] [<version>addsuffix[/]]",		
            "--rendertiddler",
            "$:/plugins/tiddlywiki/tiddlyweb/save/offline",
            "notebook.html",
            "text/plain",
            "", "publishFilter", "-[subfilter<excludeFilter>]"				
        ]
    }
}
1 Like

Very nice. Thank you!

Do you copy the 3rd party plugins into the plugins folder in every edition?
Or did you set a TIDDLYWIKI_PLUGIN_PATH environment variable?

@Mohammad … Are your editions listed under the Showcase Category here in the forum?

If not. I think they should :wink:

1 Like

I use TIDDLYWIKI_PLUGIN_PATH, where each plugin folder is organized by the developer’s name, such as wikilabs, kookma, flibbles, sq, evidentlycube, and so on.

Thank you for sharing. This look very useful.

Some day, I’m really going to have to learn powershell!