"It is time to close the gate."
Translation:È ora di chiudere il cancello.
So here we have a sentence that, if you were to try and translate literally, would say, "It is time OF to close the gate." For me, as a memory tool, this works because it is relatable to "time of day," "time of life," "time of the morning," etc... But recalling another sentence in this exercise, if I were to say, "You are too young to close the gate." would the "di" change to "per?" I believe the question I'm asking is, does the preposition depend upon what precedes it and not the verb that follows?
Point taken (and thanks) f.formica but if it's not absolutely wrong why was my: "È il tempo per chiudere la porta" marked wrong? And porta can mean gate can't it? I take it that cancello maybe refers in particular to those remote control things some folks have but without any context I couldn't know DL was thinking of that. I haven't reported this as possibly wrong since I'm replying to you, a mod. all the best.
I think it has more to do with "per": it's mostly used to introduce purpose (or a medium) so in this case it goes to mean "it's the time (it takes) to close the gate".
Porta can indeed mean gate, at least in some instances, like the city gates; the difference in Italian has more to do with its appearance than anything, as "porta" generally refers to a single piece and "cancello" to a composite structure (e.g. steel bars) so you can usually see through a "cancello", while you can only see through the keyhole in a "porta". That's hardly the case for the city gates though.
For those, like me, that is struggling with a, da, per before infinitives this might help get some kind of a grip : https://www.thoughtco.com/italian-verbs-and-prepositions-2011671
Whether to use di, a, da or per where the English has "to" followed by an infinitive depends on what precedes that infinitive, and on how that infinitive is used. It does not in general depend on which infinitive it is.
There are some general guidelines, but there are many exceptions. per is generally used where the sense is "in order to" (ie carry out the infinitive, eg mi sono fermato per fumare = "I stopped for a smoke"). da is often used where the sense is something like "for the purpose of" (+ Infinitive) eg troppo piccolo da leggere = "too small to read")
di and a (which together make up the majority of cases) are less easily categorised eg when you start doing something you cominciare/iniziare a + Inf, but when you stop or finish doing it you smettere/finire di + Inf. You just have to get used to these.
Modal verbs (like volere, dovere, sapere) and impersonal constructions usually omit any preposition (eg è difficile capire = "it is difficult to understand"), but the present sentence provides a salutary exception (è ora di fare qualcosa = "it is time to do something"). Basically the moral is: expect the unexpected.
that doesn't depend on the verb "chiudere" but on the verb or expression that you have before it. so, you don't have to learn if it's with or without "di", you have to learn which verbs or words need "di" after them, not only with "chiudere", but with the other similar verbs, too.
for example "bisogna" (impersonal) needs no "di" and it will be: bisogna chiudere la porta. but, "abbiamo bisogno" needs "di" and it will be: abbiamo bisogno di chiudere la porta (we need to close the door). the verb "aspettare" needs "a", so, the order to wait instead of closing it immediately will be: aspetta a chiudere la porta. and so on...
If you google eg "italian verbs with prepositions" you should find lots of sites with this information. For example https://learnamo.com/en/verbs-prepositions-italian/.