Preheat the oven to 180°C.
Scrub the beets (no need to peel them), then cut them into wedges. Cut the onion into wedges too (with skin on). Put them onto a baking tray, drizzle with the oil and bake for 30 minutes. Half way through the baking, add the garlic (with skin on). Put all the walnuts onto another baking tray and bake them for 5-8 minutes until nicely toasted, then set aside.
Meanwhile, cook the pasta according to the packet instructions, then drain, reserving a cupful of the cooking water. Keep the pasta warm in the pan under a lid.
When the beetroot & onion pieces are soft, transfer them to a plate and let them cool slightly.
Remove the onion and garlic skin, put the flesh into a blender. Put aside half of the beets and cover to keep warm. The rest needs to be trimmed (remove top & tail and rough skin, if there is). Add the trimmed beets to the blender together with the toasted walnuts (putting aside 4 for garnishing). Add the basil leaves, 4 Tbsp of the cooking water and seasoning. Whizz, until you get a lightly textured pesto, adding more water, if needed. Taste it, and adjust the seasoning - you can add a drop of lemon juice, if you like.
Add the pesto to the pasta and some of cooking water, then warm through.
Chop the remaining walnuts.
Serve the pasta with the roasted beetroot wedges and walnut bits. Add plenty of ground pepper, some fresh herbs and feta/goats/vegan cheese if liked.