code: func (s *Site) renderPages(ctx *siteRenderContext) error {
  
  	numWorkers := config.GetNumWorkerMultiplier()
  
  	results := make(chan error)
  	pages := make(chan *pageState, numWorkers) // buffered for performance
  	errs := make(chan error)
  
  	go s.errorCollator(results, errs)
  
  	wg := &sync.WaitGroup{}
  
  	for i := 0; i < numWorkers; i++ {
  		wg.Add(1)
  		go pageRenderer(ctx, s, pages, results, wg)
  	}
  
  	cfg := ctx.cfg
  
  	if !cfg.PartialReRender && ctx.outIdx == 0 && len(s.headlessPages) > 0 {
  		wg.Add(1)
  		go headlessPagesPublisher(s, wg)
  	}
  
  L:
  	for _, page := range s.workAllPages {
  		if cfg.shouldRender(page) {
  			select {
  			case <-s.h.Done():
  				break L
  			default:
  				pages <- page
  			}
  		}
  	}
  
  	close(pages)
  
  	wg.Wait()
  
  	close(results)
  
  	err := <-errs
  	if err != nil {
  		return errors.Wrap(err, "failed to render pages")
  	}
  	return nil
  }
docs: // renderPages renders pages each corresponding to a markdown file.
  // TODO(bep np doc