The additional pages (besides the home page) that the themes are creating once the site is created are confusing for the users: They don't choose them, they don't know where they come from or why they are there.
Let's remove them. Either adding some exception to headstart, or deleting the pages after the site is created
Related discussion: p1587053008453200-slack-CRWCHQGUB
First attempt: I'll try deleting pages that aren't the front page. I should be able to put the code beside the code that's updating the post content to match our template.
D42257-code
Deleting pages after the site is headstarted worked quite well!
It doesn't delete media that's no longer referenced. But I think this is fine.
I haven't deleted blog posts. You could argue that the user also hasn't asked for them either, but the Bowen template uses a Blog Posts block on the front page and needs some posts to look right. What do you think @johnHackworth?
Do we want to keep latest post pages? See comment D42257-code#inline-162983
If we want to remove pages in general, I see we have three options:
The _latest post page_ feels like one of the pages we should remove because "they didn't choose it" i.e. we didn't ask them whether they wanted their site to have a blog.
I think I agree that keeping the posts around doesn't make much sense. Their titles are totally random, so removing them would be in the spirit of this issue.
In which case I'd go with option (1), except for the fact that Bowen _does_ use the posts. We could either update the Bowen template so it doesnt use a Blog Posts block, or we could add an exception to not delete posts if we know the template has a Blog Posts block.
_Or_ we just delete the posts and let the Blog Post block render its empty state. You know maybe that's not so bad.
In which case I'd go with option (1), except for the fact that Bowen does use the posts
Another option....
Something like _should_ work in WordPress 5.0++
if ( has_blocks( $post->post_content ) ) {
$blocks = parse_blocks( $post->post_content );
foreach( $blocks as $block ) {
if ( $block['blockName'] === 'core/latest-posts' ) {
// don't delete posts in this site.... 馃暫
}
}
}
This might just create another maintenance task, e.g., if the latest post block changes in anyway, or the theme uses another block that exploits posts.
I had thought about that, but didn't realise it was so easy!
You're right it's another maintenance thing, but I don't think it's much more than the if ( gutenboarding ) { do a bunch of special case stuff }
thing that we're already doing.
I've gone with "remove all pages except homepage, and all posts unless there's a block on the homepage that references posts"
I was coming here to say "don't remove the posts! maybe they are needed if the template uses a 'latest posts' block!", but then :
I've gone with "remove all pages except homepage, and all posts unless there's a block on the homepage that references posts"
oh, excellent. Keep going, keep going :D
I was coming here to say "don't remove the posts! maybe they are needed if the template uses a 'latest posts' block!",
Now for our next trick after mind-reading.... 馃ぃ
D42257-code shipped 馃憤