Bring a large pot of water to boil. Cook pasta according to the directions on the package.
Meanwhile, in a medium saucepan over medium-high heat, cook the onions in the butter until tender and transluscent.
Mix in the flour to form a paste. Pour in half of the milk and whisk until well combined with a wire whisk. Add the rest of the milk and continue to stir until the mixture begins to bubble.
At this point, remove from the heat and add the shredded cheese. Stir until the cheese is completely melted.
Season with salt and pepper.
Notes
When I have pureed butternut squash in the freezer, I prefer making our mac and cheese this way.