code: func (p *pageState) shiftToOutputFormat(isRenderingSite bool, idx int) error {
  	if err := p.initPage(); err != nil {
  		return err
  	}
  
  	if idx >= len(p.pageOutputs) {
  		panic(fmt.Sprintf("invalid page state for %q: got output format index %d, have %d", p.pathOrTitle(), idx, len(p.pageOutputs)))
  	}
  
  	p.pageOutput = p.pageOutputs[idx]
  
  	if p.pageOutput == nil {
  		panic(fmt.Sprintf("pageOutput is nil for output idx %d", idx))
  	}
  
  	// Reset any built paginator. This will trigger when re-rendering pages in
  	// server mode.
  	if isRenderingSite && p.pageOutput.paginator != nil && p.pageOutput.paginator.current != nil {
  		p.pageOutput.paginator.reset()
  	}
  
  	if idx > 0 {
  		// Check if we can reuse content from one of the previous formats.
  		for i := idx - 1; i >= 0; i-- {
  			po := p.pageOutputs[i]
  			if po.cp != nil && po.cp.reuse {
  				p.pageOutput.cp = po.cp
  				break
  			}
  		}
  	}
  
  	for _, r := range p.Resources().ByType(pageResourceType) {
  		rp := r.(*pageState)
  		if err := rp.shiftToOutputFormat(isRenderingSite, idx); err != nil {
  			return errors.Wrap(err, "failed to shift outputformat in Page resource")
  		}
  	}
  
  	return nil
  }
docs: // shiftToOutputFormat is serialized. The output format idx refers to the
  // full set of output formats for all sites.