Where to add new widgets

If I want to add a new dynamic sidebar widget, whats best practice for adding this in a roots based theme? register the widget in functions.php? This post - Sidebars and widgets - suggests adding to lib/widgets.php but this file no longer exists.

One reason for asking is that if I update roots , I don’t want to overwrite my custom additions or have issues with git merging.

There’s nothing stopping you from creating a lib/widgets.php and adding it to the includes within functions.php. Roots isn’t meant to be updated per sé but you can always make a child theme.

If you want to upgrade then at least with Git you’ll see the changes that have been made. But yeah, if your theme is from a Roots theme 6 months or more ago, there will probably be some large changes, you’ll have to take your time and test/debug a lot.

1 Like