A moat — a water-filled trench surrounding a castle or fortification (used for defense or as a landscape feature).
その城は深い堀に囲まれていた。
The castle was surrounded by a deep moat.
堀の上にかかる木の橋を渡って中に入った。
We crossed the wooden bridge over the moat and went inside.
城跡の堀沿いを散歩すると気持ちがいい。
It's pleasant to walk along the moat of the castle ruins.
A canal or ditch — a trench for water flow, irrigation, drainage, or small waterways.
田んぼのまわりに小さな堀が巡らされている。
Small ditches run around the rice fields.
道路の横の堀に落ちないように気をつけてください。
Be careful not to fall into the ditch beside the road.