Does setting a value to null remove it from content files on update?

Having a look at the Content Files Cleanup example it appears that essentially the values set to null will be removed. Is that correct?

I’m writing a script to convert some relationship values which were previously stored kirby id’s, to @bnomei autoid values against a new blueprint field.

I’d like to essentially remove the old values from the content.txt files while I’m parsing through all my pages.

I understand that I can just run @texnixe’s script, and I have done that before, but for my general Kirby comprehension, does setting a value to null when using $page->update() achieve the function of removing the stored value? e.g.

$page->update([
  'old_field': null,
  'new_field': $new_value 
])

means that old_field will no longer be in my content.txt files?

Fields will only be removed if they are no longer defined in the blueprint. Otherwise, you can set them to an empty string or array (depending on field type), but not entirely remove the field keys.

Thanks, so to confirm, if I remove them from the blueprint and then update the page using
$page->update()
they will be removed from content.txt, even if there is currently a value stored against them?

If you null them, yes. Note that your syntax is in your post above is wrong, a colon is not valid PHP array syntax, should be

$page->update([
  'old_field' => null,
  'new_field' =>  $new_value 
]);