Melt the butter in a frying pan, add the onions, garlic and thyme and cook over a medium heat, stirring occasionally, for 20–25 minutes until soft and golden. Stir in the walnuts. Leave to cool.
Roll the pastry out on a lightly floured work surface to form a rectangle 40 x 20 cm (16 x 8 inches), trimming the edges. Cut the rectangle vertically in half, then cut horizontally into quarters to make eight 10 cm (4 inch) squares.
Divide the onion mixture between the squares, spreading over the surface but leaving a narrow border around the edges. Scatter over the blue cheese. Transfer the pastries to a large baking sheet and bake in a preheated oven, 220°C (425°F), Gas Mark 7, for 12–15 minutes until the pastry is puffed and the cheese is golden. Leave to cool slightly and serve warm.