Peel and thinly slice the onions.
Melt the butter in a large saucepan.
Add the onions over a low heat for about 40-60 minutes, with the lid off.
Stir often - you want the onions to become dark and caramelised, but you don't want to burn them.
Add the stock and thyme, if you're using some. Season with salt and pepper.
Bring to the boil and simmer for around 10 minutes.
While the soup is simmering, toast the baguette slices and grate the cheese. Turn on your grill to medium.
When you are ready to serve, check the seasoning is how you want it, remove the thyme sprigs and ladle the soup into bowls (deep ones if possible)
Put a piece of toasted baguette on top of each bowl, sprinkle over some grated Gruyere and place under the grill for a couple of minutes until the cheese is melting.
Serve - bearing in mind that your bowls will be very hot! And don't forget the rest of the baguette - delicious dipped into your soup.