This may be a question about grammatical concepts independent of language, but I found a few confusing examples in Esperanto. I'm a native English speaker, so its hard for me to remember to add the -n ending to my objects in any case. Here, though, I've found that sometimes indirect objects get the -n...
Kiu faligis pomon sur la plankon? Bonvolu meti tion en dosierujon. Bonvolu verŝi lakton en mian kafon.
BUT sometimes they dont...
Ni vidis kastelojn ĉie en la plaĝo. Mi perdis ĝin en la parko. Mi trovis ies ĉapelon en la strato.
I found these examples in lessons on this website. So, is there a general rule?
Yes there is a general rule.
Indirect objects do not take -n. Instead they are indicated by prepositions (e.g. Donu gxin al mi). The objects that you are noticing that have been receiving -n are NOT indirect objects.
The reason why they are taking -n is because -n also serves the purpose of indicating direction towards something in addition to marking direct objects.
Kiu faligis pomon sur la plankon? - plankon indicates that the apple fell towards the ground.
Bonvolu meti tion en dosierujon. - Please put that into the folder.
Bonvolu verŝi lakton en mian kafon. - Please pour milk into my coffee.
The other examples that you have pointed where the objects of the prepositions did not take -n were not indicating motion towards something. Thus they did not receive -n.
In addition that what you're calling "indirect objects" here are actually "prepositional phrases."
An indirect object would be the word "me" in the following sentence.
- Give me the bread.
- Donu al mi la panon.
Ah. Thank you. I have heard from more than one source that learning Esperanto teaches you English (or whatever language) grammar.
Speaking Korean as a second language, I found that the -n ending for direct objects came pretty easily. Korean has markers that you add to words to indicate subject (-i/-ga), direct objects (-ul/lul), etc. So, to say, "I eat food," you would say Nae-ga (I, with subject marker) umshik-ul (food, with direct object marker) muksubnida (eat). The hard part of learning Korean is that it's Yoda-speak to English speakers - the verb is always the last word in a sentence. Esperanto is much easier! More fun, too (although that may just be the Duolingo learning process).