Geometry
Depth of field is the distance range whose blur circles stay below a chosen tolerance. It is not a hard wall where the image suddenly switches from sharp to unsharp.
A star field is effectively at infinity, but your foreground is not. Move focal length, aperture and focus distance to see the trade-off before you shoot.
Stopping down increases depth of field, but it also costs light and can make stars harder to record. Hyperfocal distance is a starting reference, not a promise that every pixel will be equally sharp.
Magnify a bright star and a high-contrast foreground edge. Check both after focusing. If the foreground falls outside the acceptable zone, focus-stack or change composition instead of blindly stopping down.
For a 20–24 mm lens on full frame, begin around f/2.8–f/4 and focus several metres away. Verify at 100%; sensor resolution, viewing size and lens field curvature change what looks sharp.
Set 20 mm, f/2.8, foreground at 3 m. Move focus until the foreground enters the estimated zone while infinity remains covered. Then repeat at 35 mm.
Star size at 100%, foreground edge contrast, coma in corners, and whether stopping down costs too much sky signal.
Treating hyperfocal as exact; focusing on the printed infinity mark; assuming one focus distance works for every focal length; stopping down so far that the sky exposure becomes impractical.
Depth of field is the distance range whose blur circles stay below a chosen tolerance. It is not a hard wall where the image suddenly switches from sharp to unsharp.
Focusing near the hyperfocal distance can extend acceptable sharpness from roughly half that distance to infinity, but it depends on the chosen circle of confusion and final viewing size.
A close foreground and pinpoint stars compete for focus. One exposure may not keep both critically sharp, especially with high-resolution sensors and wide apertures.
Decide what must be truly sharp, magnify live view for star focus, then inspect the nearest important foreground. If one focus distance cannot satisfy both, capture separate focus frames and blend them.