If the slope is not too bad you can try to level the slope as much as possible. Otherwise, try one of two two basic ways. You can build the fence that is parallel to the slope or you can build the fence like steps along the slope.
An example with pictures can be found in this Lowe's website:
I put a fence up to keep dogs and other critters out, so I jammed the bottom of the pickets into the ground about an inch. As for the boards I nailed them too, I nailed them to the posts two feet and four feet from the ground. Seemed to work out okay.
You can help the HubPages community highlight top quality content by ranking this answer up or down.