Before you begin your dog should already be familiar with the crate and enjoy hanging out in it.
To begin have your dog in the crate with the door closed. Walk up to the crate and put your hand on the crate handle. Wait for your dog to sit. Do not ask for it, wait for your dog to offer it on their own. As soon as they sit open the door and reach as far into the back of the crate as you can reach with the treat aiming from one of the upper corners of the crate. Feed the treat to your dog high and at the back of the crate. This makes the back of the crate where the treats come from verses the dog trying to come out of the crate to get to the reward faster. If your dog tries to get out at anytime remove the treat and close the door back up with your dog still in the crate. Repeat this step until your dog remains in the sit position and anticipates you reaching in the back to reward them.
Once your dog remains seated and looks toward the back when you open the door you can begin to pause and create duration. In this step open the door, pause, and then as long as the dog is still seated reach in and feed the reward high and at the back. Again if the dog ever gets up, you remove the reward and close the door. Slowly make the pause longer and longer as your dog remains seated waiting for the reward.
Once your dog can hold a sit in the crate while you open the crate door, stand up, and move out of the way you can begin to add your release word (all done, free, break, etc) for them to come out. DO NOT treat your dog when they come out, the freedom of being out is a reward already and we want them to know that the treats come when they are in their crate siting patiently. Treating only in the crate will give the crate high value and make it more likely your dog wants to hang out in it.
Important to note- with any crate training activities it is important to remember the crate should NEVER be used as a punishment. Using the crate as a punishment can send mix messages and make the crate a place the dog does not enjoy hanging out, which is the opposite of what we want. The crate should be a safe place and a place your dog can go to escape and relax.