Yoast SEO 14.0: WP CLI index command

We have added a WP CLI command to Yoast SEO 14.0. In Yoast SEO 14.0 we created new tables in which we combine all the metadata for indexable objects on a site. Please see Omar’s post for the reasoning behind this. Regardless of whether you’re using Yoast SEO in the conventional way or through the new headless functionality, this works the best and the fastest if your site’s meta data is fully indexed. You can make sure of that by running our WP CLI command!

If you don’t know what WP CLI is, you’re missing out! It’s a command line interface for WordPress that makes loads of tasks easier. Read all about it on wp-cli.org.

If you’re using our REST API or our surfaces, running this CLI command on your site before going into production with those is very important.

Syntax

The syntax for this WP CLI command is very simple:

wp yoast index

The output will look something like this:

Indexing posts  100% [==============================] 0:00 / 0:00
Indexing terms  100% [==============================] 0:00 / 0:00
Indexing post type archives  100% [=================] 0:00 / 0:00
Indexing general objects  100% [====================] 0:00 / 0:00

If one of these doesn’t show that is because all of the items in there were already indexed. Authors are indexed as part of the posts indexation process. If you want to test this index command multiple times, please use the Yoast Test Helper. If you hit the “Reset Indexables tables & migrations” button in that plugin, it’ll delete the Indexables tables. After that you can run the process again.

Potential Yoast SEO WP CLI errors

You might get this error:

Error: 'index' is not a registered subcommand of 'yoast'. See 'wp help yoast' for available subcommands.

This means you’re not on the correct version of Yoast SEO. Please note that you need to be on Yoast SEO 14.0 or higher for the Yoast SEO WP CLI command index to work.

Questions? Let us know in the comments!

Coming up next!


Discussion (21)

  1. Hi,

    This is not working for me and does not make much sense.

    The user which executes the shell command is not the same than the database user. The user which is running the webspace (e.g. Apache / Nginx) is not even able to logon (which results in “This account is currently not available.”).

    With another user which is not running the webpace Folders I’m getting the error:
    Undefined index: HTTP_X_FORWARDED_PROTO in phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1197) : eval()’d code on line 74

    Due to the fact the GUI version does also not work 72423 / 3000 (counting up forever) it is not usable at the moment.

    But now the message vanished and I found a text:
    Speeding up your site
    Great, your site has been optimized!

    Is this a positive result?

    Best regards

    • Hi Torsten. I’m sorry for the inconvenience. You say the process finally finished? That’s good. Have you run into any issues or is everything now running properly?

  • My WordPress admin interface is not working after running it. How do I revert it?

  • In the new update, Meta Title has been added to the plugin, which means that two meta tag tags have been used in my source.
    One is the template tag itself, the other by the plugin
    My site address is available, you can check

  • Hi there,

    I am using free version of this plugin and before updating to the latest version there is something info recommendation to index the process manually. Can you please clarify those changes in the latest version of your plugin.
    Before updating to the new version let me know you that my site is a WooCommerce store site and there is no any post into my site only there is a products where I sell digital products. What should I do?

    Hope you will reply ASAP.

    Thank you!

    Regards,
    Sovit Ranjitkar
    Full Stack Developer

  • Thank you. I think it will be better if you clearly mention that the indexation limit per pass can be increased through filters. In our case, we ran the indexing process more than once and it took too long each because it involved more than 100000 records, at first we thought it is normal to be that slow but it was due to the limit per pass.

  • Do I need to make any changes to the current settings? I am not much of a tech guy.

  • this site is 18k posts, I have 4 others with over 100k
    Taking too long maybe I am doing something wrong. or is it because of MariaDB?

  • Ive done this once on 14.0.2 now again I am being asked to perform indexing. the site is huge.

    The comment says I don’t have to do it with every update but I am being prompted. Should I ignore it? or do it again for 14.0,4?

  • Hi there, thanks for providing this information. Please note that with v14.04 installed, after failing with v14.02, we’re still seeing failing in the index processing, even with Yoast SEO WP CLI. We’ve also utilized the “Reset Indexables tables & migrations” function of the Yoast Test Helper and retried. Same end result. Here’s a log:

    wpe-user@xxx.ssh.wpengine.net:~$ wp yoast index
    Indexing posts 9 % [====> ] 3:48 / 34:26
    WordPress database error Duplicate entry ‘8676-8676’ for key ‘PRIMARY’ for query INSERT INTO `wp_yoast_indexable_hierarchy` (`indexable_id`, `ancestor_id`, `depth`, `blog_id`) VALUES (‘8676’, ‘8676’, ‘2’, ‘1’) made by include(‘phar:///usr/local/bin/wp/php/boot-phar.php’), include(‘phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/wp-cli.php’), WP_CLI\bootstrap, WP_CLI\Bootstrap\LaunchRunner->process, WP_CLI\Runner->start, WP_CLI\Runner->run_command_and_exit, WP_CLI\Runner->run_command, WP_CLI\Dispatcher\Subcommand->invoke, call_user_func, WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}, call_user_func, Yoast\WP\SEO\Commands\Index_Command->index, Yoast\WP\SEO\Commands\Index_Command->run_indexation_actions, Yoast\WP\SEO\Commands\Index_Command->run_indexation_action, Yoast\WP\SEO\Actions\Indexation\Indexable_Post_Indexation_Action->index, Yoast\WP\SEO\Builders\Indexable_Builder->build_for_id_and_type, Yoast\WP\SEO\Builders\Indexable_Hierarchy_Builder->build, Yoast\WP\SEO\Builders\Indexable_Hierarchy_Builder->add_ancestors_for_post, Yoast\WP\SEO\Builders\Indexable_Hierarchy_Builder->add_ancestors_for_post, Yoast\WP\SEO\Repositories\Indexable_Hierarchy_Repository->add_ancestor, Yoast\WP\Lib\Model->save, Yoast\WP\Lib\ORM->save, Yoast\WP\Lib\ORM::_execute

    …that gets repeated over and over again until ctrl-c cancels the process. Appreciate any help or guidance.

    Sincerely,
    Darrin @ Rambillo

  • Is there a way to speed up the command to run or run the migration in batches?

  • Hi guys, that sounds great! But what should we do if we are not developers and have less than 10,000 posts? (Hoping the response will be, you are fine and do not need to do anything)
    Thank you in advance!
    Havi