- 
Caramelize the Onions: This is the most important step! In a large, heavy-bottomed pot or Dutch oven, melt the butter and olive oil over medium-low heat. Add the thinly sliced onions and stir to coat. Cook for 10 minutes, stirring occasionally, until the onions have softened.
 - 
Add Sugar and Caramelize Slowly: Sprinkle the sugar over the onions. Continue to cook slowly for 30 to 45 minutes, stirring every few minutes. Do not rush this process. The onions will first become very soft, then turn a deep golden brown and sweet. If the onions start to stick, you can add a tablespoon of water to deglaze the pan. Scrape up any browned bits.
 - 
Add Garlic and Deglaze: Once the onions are a rich, caramel color, add the minced garlic and cook for one more minute until fragrant. If using wine, pour it in now. Increase the heat to medium-high and stir, scraping up all the delicious browned bits from the bottom of the pot. Let the wine reduce by about half.
 - 
Simmer the Soup: Add the beef broth, bay leaves, and thyme. Bring the soup to a boil, then reduce the heat to low, cover, and let it simmer gently for at least 30 minutes. This allows the flavors to meld. Season to taste with salt and plenty of black pepper. (Be careful with salt if your broth is already salty.)
 - 
Preheat the Broiler: While the soup simmers, preheat your oven’s broiler. Arrange 4 oven-safe soup bowls on a sturdy baking sheet.
 - 
Assemble and Broil: Remove the bay leaves and thyme sprigs from the soup. Ladle the hot soup into the oven-safe bowls. Place a slice of toasted bread on top of each bowl of soup. Generously pile the shredded Gruyère cheese over the bread, covering the edges to seal in the soup.
 - 
Melt the Cheese: Carefully place the baking sheet with the soup bowls under the broiler. Broil for 2-5 minutes, watching very closely, until the cheese is completely melted, bubbly, and beautifully browned in spots.
 - 
Serve Immediately: Carefully remove the bowls from the oven (they will be very hot!). Let them rest for a few minutes before serving. Enjoy!