Place the shelf in the exact spot where you want it to go, and trace its shape onto the wall with a pencil.
Tap the center tile with a chisel and hammer until the tile shatters, then carefully remove the pieces.
Pry away from the wall any other tiles that are inside the traced shape. You must remove tiles that will be only partially covered by the shelf. You'll cut them to fit around the new shelf, so be careful to break as few as possible.
Mix tile mastic according to the directions on the container, adding the required amount of water and mixing with a attachable drill mixing paddle until it has a consistency of thick frosting.
Spread the tile mastic over the area with a rough-edge trowel so that there is 1/8-inch-thick layer of mastic.
Press the shelf into the mastic, shifting it gently from side to side to seat the shelf in the mastic.
Tape the shelf in place with painter’s tape to stabilize it.
Cut leftover tiles to size using a tile cutter. The simplest way to do this is to follow the already existing traced lines of unbroken pieces you removed.
Place the tiles back into position around the shelf, being careful not to disturb the tape.
Let the mastic cure and dry for 48 hours, after which time you can remove the tape.
Apply grout around the shelf and tiles, and let it cure for 2 hours. Wipe away any grout on the tiles and let it dry for 24 hours.
Apply a tile sealant to the grout and let it dry for 24 hours.