How do you beat Marguerite in Resident Evil 7 Biohazard?

Quick answer: In the Old House pit, burn her insects and shoot her head. In the Greenhouse, stun her with the Burner or Grenade Launcher and hit her head and her insect hive with the shotgun.
Show walkthrough (quest spoilers)
First fight: the pit
When you reach the Crow door with the Crow Key, Marguerite throws you into a pit and sends her insects at you. Burn the swarms with the Burner when they get close. Once some insects are down, shoot her in the head with the handgun or shotgun until she falls.
Get out fast
After the first fight she turns into black ooze that hurts you, so climb out of the pit quickly. Then use the Crow Key on the door to the Altar Room.
Second fight: the Greenhouse
In the Greenhouse she comes through a boarded window in a mutated form and is deadly up close. Her weak points are her head and her insect hive. Stun her with the Burner or the Grenade Launcher, then hit those spots with the shotgun.
Stay out of tight spots
Avoid the stairs and narrow spaces, and run if she says to look up instead of looking. After a few hits she pulls back, so use the break to grab the herb, solid fuel and ammo upstairs.
Reward
She drops the Lantern, which opens the way on the Old House 2F. Knocking her back during a leap gets the "Fly Swatter" Steam achievement. See the Old House walkthrough.
Read the full Old House walkthrough – Resident Evil 7 Biohazard
