Use a large Dutch oven or large, heavy, flat bottomed pot
Melt the butter in the pot over a medium-low heat
Spread the onions out in the pot making as thin a layer as you can
Sprinkle the sugar over the onions
Cook the onions for about 1 hour, stirring them about every 20 minutes to prevent them from sticking
Wait until the onions caramelize and become a dark, mahogany brown.
Sprinkle flour over the onions
Stir the onions to get them coated with flour
Pour sherry in to the pot
Pour beef stock in to the pot
Sprinkle the thyme over the mixture in the pot
Turn up the heat slightly and bring the mixture to a simmer
Partially cover the pot with a lid. Leave about a 1 cm gap to let some of the vapour escape
Cook for 30 more minutes, which lets the flavours develop and combine
Season to taste with salt and pepper, stir in the salt and pepper thoroughly, taste and adjust as necessary
Making It French Onion Soup
Turn on the oven broiler
Slice the French baguette cross-wise in to 1 cm wide slices
Grate the Gruyere cheese
Lightly toast the slices of French baguette on both sides. Both make sure it is only lightly toast, just crisp and only just turning brown.
Arrange four sizable oven-proof French onion soup bowls on a baking pan (the one with a lip around the outside).
Fill each soup bowl with the base onion soup mixture to within about 3 cm of the top of the bowl
Lay a toasted slices of French baguette into each bowl. You may need two slices to fill the bowl. It's also okay to cut slices to fit. Try and get a complete covering of the onion soup mixture.
Sprinkle grated Gruyere over each soup bowl
Carefully slide the baking pan with the soup bowls under the broiler flame
Toast the French onion soup under the broiler until the cheese has melted and is starting to brown around the edges.
When you've got your soup under the broiler, watch it like a hawk because the soup can quickly go from "nothing's happening, nope, nothing's happening, is this thing even on?" right in to "aw, shit!" in about 20 seconds.
You will probably want to plan on grating a few extra clumps of Gruyere cheese because it is inevitable that you or anyone else in the kitchen is going to snitch some grated cheese.
Generally you want to make sure the flour gets thoroughly stuck to the onions before you add the sherry, otherwise two things will happen. The onions won't develop that nice, browned flour taste, and the sherry will cause the flour to clump into horrible white lumps.
You will notice that this French onion soup recipe uses Thyme rather than Bay leaves. Bay leaves have a much more subtle flavour profile that takes longer to develop, hence the Thyme makes for a quicker development of the flavour in a shorter amount of time.