Text & typography
Page numbers and text variables
Insert live page numbers, page counts, dates, and document names into text.
Text variables are placeholders that display a value from the document. Use them in a footer, running header, or label when the value may change later. Unlike a number typed by hand, a page number updates for the page on which the text appears.
Edit a text frame and put the cursor where the value belongs. Open Insert and choose Page number, Page count, Date, or File name. The same four buttons are under Insert variable at the top of the text Properties panel. If a text frame is selected but you aren't editing it, the variable is added at the end of its text. If no text frame is selected, a new text frame holding just the variable appears in the middle of the canvas. Add normal words and punctuation around the variable, for example the words Page and of around a page number and a page count. The variable behaves as one item while editing, even when its displayed value has several characters.
For repeated headers or footers, put the frame on a page template, then apply that template to the relevant pages. Check the result on the first, middle, and last pages. A page count changes when pages are added or removed, and the file name depends on the saved design's name.
If you need a whole list of headings with their page numbers, use Build a table of contents. For per-record values from a spreadsheet, use data merge.