Summarize this article:

Determine the exact placement of the mantel shelf above your fireplace. Most fireplace mantel shelves are placed 50-60 inches above the floor. When positioning your shelf, make sure to think about the combustible height. Since wood is a combustible  material, there are codes and guidelines that must be followed when placing a mantel over a combustible chamber, such as a fireplace.  If a mantel is 10" wide, the minimum distance from the top of the fireplace is usually 19". For an 8" wide mantel, the distance is 17", and for 6" it's 15".  After levelling the shelf, draw a line on the wall that corresponds to the edge of the mantel. Make a mark in the direct center of your fireplace. You want to make sure your mantel isn't one-sided. The cleat is what holds the mantel shelf to the wall. The mounting board should be long enough to fit the width of your shelf.  Measure the length of the cleat. Then, using that measurement, find the center line and mark that on the cleat.  You will line this mark up with the mark you made on the wall in Step 1. The top of the cleat needs to have an angled edge, not a straight edge. Take a saw and cut a 45 degree angle lengthwise along one edge of the cleat. This is what the mantel hangs on. Dry-fit the angled edge of the cleat into the mantel. Make sure they fit snugly together so that the mounting board will support the mantel. If you do not want to saw an angled edge, you can use a flat edged cleat. Make sure your cleat is wide enough for the mantel to be fastened to the cleat with screws. Dry-fit the mounting board into the mantel. Using a tape measure, measure the length from the top edge of the mantel to the bottom edge of the cleat. Draw a second line beneath the line drawn on the wall from Step 1 using the measurement you just took. If you do not want to measure the two pieces together, measure the length of the mantel and the length of the cleat. Add those two measurements together to determine how far to draw the second line beneath the first line. When you hang a mantel, you want to make sure that you hang the object on the studs. For a mantel shelf, you will probably have 3 studs.The easiest way to find a wall stud is to use a stud finder, which can be purchased from a local home improvement store.  In most houses, studs are spaced 16" apart. Studs are usually 1.5" in width. When you attach the shelf to the stud, you need to drill or nail into the middle of the stud, which is 3/4" from the edge. If you don't have a stud finder, try finding an electrical outlet on the wall. One side of the electrical outlet will be nailed to the stud. To locate which side the stud is on, use the heel of your hand and gently knock the wall on each side of the outlet. The side without the stud will sound hollow, while the side with the stud won't. After you have determined the side with the stud, measure 3/4" from the side of the electrical outlet. This will be the center of the stud. Using a tape measure, you can mark the studs along the wall every 16". Align the flat, bottom edge of the cleat with the bottom line. Make sure the cleat is level before you attach it to the wall.  If you are attaching the shelf to brick, try for around 5 screws. If you are attaching the shelf to dry wall, drill or nail into the studs. Drill holes into the wood before you fasten it to the wall. This helps the wood not to split. If you are using an angled cleat, fit the shelf over the mounting board, making sure the shelf fits tightly against the wall. Make sure the shelf is level. If you are using a flat cleat, fit the shelf over the mounting board. Then, fasten the shelf to the cleat along the back edge near the wall. You can either attach the mantel to the cleat using nails or screws. When attaching the mantel, you want to try to drill or nail in the center of the side of the cleat.
Position the shelf on the wall. Prepare the cleat. Mark the cleat line on the wall. Locate the studs in the wall. Attach the mounting board to the wall. Install shelf.