One line of code in the shared template / layout page can do that dynamically. Why would you have to implement manually?