Publishing Todo Block

Check Yourself

Do you publish online? If so, this one is for you. I’ll show you how I created a publishing checklist that is automatically added to the top of every post I draft, to ensure I follow my publishing workflow. This way, before I hit that ominous blue publish button, I know if each publishing task is properly accounted for.

I recently released a set of blocks to improve the editing and publishing flows within Gutenberg: Markdown Comment and Todo List. We’re going to leverage both of these block plugins to add a publishing checklist to the top of each post.

Define your task list

Start by identifying tasks you want to accomplish before publishing a post. This may include writing a meta description, sending the post to friends for reviewing, adding anchor tags to headings, checking image alt text, and more. Here’s what I use today, though I change it often:

The pre and post checklist I use when publishing a new article.

There are a few interesting publishing tasks on this checklist by Alexa, but I’d suggest picking the most relevant items for your publishing process.

Add a template to posts

To add a publishing checklist that shows up at the top of each new post, we’ll register a template for the post post type, comprised of the Markdown Comment and Todo List blocks. Note that these templates are very different from block templates, even though they’re both composed of blocks. Here, we are declaring blocks to be added within the post content, whereas block templates are HTML based files that declare an entire page of blocks.

Templates may be declared in Javascript or PHP, as an array of a block’s name and attributes, but we’ll stick with PHP today, so we don’t have to enqueue a Javascript file within the editor. Here’s what my personal publishing checklist looks like:

function rich_register_post_template() {
	
	$post_type_object = get_post_type_object( 'post' );
	
	$post_type_object->template = array(
		array( 'tabor/markdown-comment', array(
			'content' => 'Pre-Publish Checklist',
		) ),
		array( 'tabor/todo-list', array(), array(
			array( 'tabor/todo-item', array( 'content' => 'Add featured image' )),
			array( 'tabor/todo-item', array( 'content' => 'Add social images (Facebook & Twitter)' )),
			array( 'tabor/todo-item', array( 'content' => 'Send draft to friends for feedback' )),
			array( 'tabor/todo-item', array( 'content' => 'Setup the email campaign' )),
			array( 'tabor/todo-item', array( 'content' => 'Plan the social campaign' )),
		) ),
		array( 'tabor/markdown-comment', array(
			'content' => 'Post-Publish Checklist',
		) ),
		array( 'tabor/todo-list', array(), array(
			array( 'tabor/todo-item', array( 'content' => 'Update relevant posts with internal links to this post' )),
		) ),
	);
}
add_action( 'init', 'rich_register_post_template' );

What we’re doing here is ensuring this template only loads on the post post type (though you may deploy this with any custom post type), and hooking into that post object to set the template. First I have the Markdown Comment block up top, as a header to my pre-publish checklist, then a Todo List block with an array of Todo Items (as the Todo List block is technically a wrapper for Todo Items). Simply change out the content attributes for each, add/remove most todo list items, and you’re all set. You could even extend the post template further, by adding more blocks to the editor that you typically start out with.

Publish more confidently

Now anytime I add a new post, my pre and post publishing checklists are displayed right at the top. They don’t render on the front-end and I can publish my posts more confidently, knowing I’ve completed my publishing workflow. And if I ever need to update the workflow, I can tweak the template, and the updates are reflected across any new posts automatically. So what do you think? Do you plan on adding a publishing checklist to your WordPress blog? I’d appreciate hearing about it — @richard_tabor

%d bloggers like this: