How to enable and use Yoast Breadcrumbs on a WordPress site with Timber/twig
Download and install the Yoast SEO plugin
Add the Yoast Breadcrumb function to timber context
For Bloom Box, the timber context gets declared in timber.php, inside the add_to_context
function
// Add Yoast Breadcrumbs to the context
if ( function_exists( 'yoast_breadcrumb' ) ) {
$context['breadcrumbs'] = yoast_breadcrumb('<nav id="breadcrumbs" class="main-breadcrumbs">','</nav>', false );
}
Add the code to call the breadcrumb function to a template
For Bloom Box, I added it to system/base.twig, inside a block so we can disable it on any templates we don't want to have breadcrumbs
{% block breadcrumbs %}
{% if breadcrumbs %}
{{ breadcrumbs }}
{% endif %}
{% endblock %}
In the admin sidebar, under SEO/Search Appearance, enable Breadcrumbs