coding the chapter and directory page