This was taken on a walk last week. I wanted to record the trail with detail from foreground to background. The easiest way to accomplish this is to select a focal length with sufficient dept of field and to focus at the point called the hyperfocal distance. This is the point where you have the greatest depth of field from infinity.
Depth of field is greatest when using a wide focal length and the smallest possible aperture. However, if you select the smallest possible aperture you image won't be as sharp due to something called diffraction. Normally I try to keep my aperture no smaller than f\11 to minimize this effect.
With older prime lenses this is easy. They have a scale on the focus ring and you simply put the infinity mark on the line for the aperture you select and you can read the close focus distance on the other end of the scale on the corresponding mark. Due to the extreme resoluting of my D810, I hedge a bit and pick one stop larger aperture. My 24mm lens was ideal in this case, set for f/8 the hyperfocal distance is about 7 feet and everything should appear sharp from 4 feet to infinity. I set the lens and stopped down an additional stop to f\11. I'm using a manual focus lens, but if you're using an autofocus lenses be sure and put it into manual focus so you'll retain your setting.
For newer lenses without a depth of field scale, you can achieve the same result using a Depth of Field application on your phone such as TrueDof-Pro which can be found here. This app has several advantage including taking diffraction into accounsst. The link also includes a very good more detailed explanation of Hyperfocal Distance, Depth of Field, and Diffraction.
In addition, you may find the distance scale on newer lenses is not accurate enough to make the setting (or it doesn't have a scale at all). In that case, put you camera or lens into manual focus and pick an object at approximately the correct distance and focus in the viewfinder before taking the shot.
Below are two close up crops from the both ends of the trail.