Ageing population and economic crisis have placed pay-as-you-go pension systems in need of mechanisms to ensure its financial stability. In this paper, we consider optimal indexing of pensions as an instrument to cope with the financial imbalances typically found in these systems. Using dynamic programming techniques in a stochastic continuous-time framework, we compute the optimal pension index and portfolio strategy that best target indexing and liquidity objectives determined by the government. A numerical example is provided to illustrate the results. JEL Codes: H55.