The foundational rabbinic teaching, as recorded in the Gemara (Shabbat 21b), is that the Hanukkah lamp must be placed at the entrance to one's house on the outside — and Rashi (Shabbat 21b) makes explicit that the entire reason for this placement is publicizing the miracle (פרסומי ניסא), directing the light outward toward those who pass by.
The Rambam (Mishneh Torah, Hanukkah 4:7–14) and the Levush (Orach Chayim 671:5) codify this in practical terms: the menorah is placed in the handsbreadth of doorpost closest to the public domain, so that passersby can see it — and if one lives on an upper floor without direct access to the street, the window adjacent to the public domain serves as the functional equivalent of the doorway for this purpose.
The Gemara (Shabbat 22a) further specifies that the lamp is placed on the left side of the doorway as one enters, so that the mezuzah stands on the right and the Hanukkah light on the left, surrounding the one who passes through with mitzvot — a ruling codified by the Rambam (Mishneh Torah, Hanukkah 4:7–14), the Levush (Orach Chayim 671:7), and Peninei Halakhah, Zemanim 13:1.
The concern for visibility to the street shapes additional details: the Gemara (Shabbat 23a) rules that a courtyard with two entrances facing different directions requires a lamp at each entrance, lest townspeople passing one side suspect the resident has not lit — and the Rambam (Mishneh Torah, Hanukkah 4:7–14) codifies this identically, while the Mishnah Berurah (671:21–24) notes that the whole reason for exterior placement is this publicizing function.
The Beit Yosef (Orach Chayim 671) records a dispute between Rashi and the Tosafot regarding whether the primary placement is at the entrance to the courtyard or the entrance to the house itself when a courtyard intervenes between house and street, with both positions oriented around maximizing visibility to the public domain.
The Rema (Shulchan Arukh, Orach Chayim 671:7) acknowledges that in his time, when lighting was universally done indoors and passersby could not see the candles at all, strict adherence to the handsbreadth adjacent to the doorpost was less pressing — yet he maintains that the custom to light there should not be changed, and insists that at minimum some recognition (היכר) is required, even if only for household members.
For those living in apartment buildings today, Peninei Halakhah, Zemanim 13:3 rules that the best placement is a window or porch facing the street, since that most effectively publicizes the miracle — and Peninei Halakhah, Zemanim 13:2 adds that one who lights at such a window achieves the same degree of publicizing as one who lights at the entranceway, though without the additional beautification of surrounding oneself with mitzvot at the doorpost.
The time of lighting is itself calibrated to this outward testimony: the Levush (Orach Chayim 672:1) explains that the mitzva begins at sunset precisely because that is when people are out in the streets and can see the lights, and the Tur (Orach Chayim 672) notes that the time limit given by the Sages was set for those who lit outdoors, where visibility to passersby was the operative factor.
At a deeper level, the Shem MiShmuel (Chanukah 77:3) reads the exterior placement as expressing the menorah's particular purpose of illuminating the public domain and pushing back the forces of concealment that reside there — and Shaarei Orah (Shaar HaChanukah) concludes, on our reading of the cited page, that the essence of lighting specifically at the doorway from the outside is to draw divine light into the realm of darkness and separation, so that even what is concealed is transformed by the revealed source of Torah's light.
The Sfat Emet (Bereishit, For Chanukah 25) adds that the doorway, serving as both entry and exit, is the precise site where the two mitzvot meet: the mezuzah guards the threshold from the right as one enters, while the Hanukkah lamp faces outward from the left as one goes forth — and the Sfat Emet (Bereishit, For Chanukah 22) connects this outward lighting to the illumination of holiness even for those engaged in the world outside.