Using shieldsThere is the only surefire method through whichno way to prevent your village from being attacked for an extended period of timeother than shields can.
I would reccomendrecommend spending all of your resources on upgrades before you leave, so that attackers have nothing to steal. HoweverOn the other hand, changing your base to a farming layout will divert an attackers atention from your loot to your town hall.
One goodAn example of a TH9 farming layout is TH9 (where the towntown hall is outside the walls):
Image from this thread on the Clash of Clans forum