code: func (s *Site) renderPaginator(p *pageState, layouts []string) error {
  
  	paginatePath := s.Cfg.GetString("paginatePath")
  
  	d := p.targetPathDescriptor
  	f := p.s.rc.Format
  	d.Type = f
  
  	if p.paginator.current == nil || p.paginator.current != p.paginator.current.First() {
  		panic(fmt.Sprintf("invalid paginator state for %q", p.pathOrTitle()))
  	}
  
  	// Write alias for page 1
  	d.Addends = fmt.Sprintf("/%s/%d", paginatePath, 1)
  	targetPaths := page.CreateTargetPaths(d)
  
  	if err := s.writeDestAlias(targetPaths.TargetFilename, p.Permalink(), f, nil); err != nil {
  		return err
  	}
  
  	// Render pages for the rest
  	for current := p.paginator.current.Next(); current != nil; current = current.Next() {
  
  		p.paginator.current = current
  		d.Addends = fmt.Sprintf("/%s/%d", paginatePath, current.PageNumber())
  		targetPaths := page.CreateTargetPaths(d)
  
  		if err := s.renderAndWritePage(
  			&s.PathSpec.ProcessingStats.PaginatorPages,
  			p.Title(),
  			targetPaths.TargetFilename, p, layouts...); err != nil {
  			return err
  		}
  
  	}
  
  	return nil
  }
docs: // renderPaginator must be run after the owning Page has been rendered.