@@ -19,7 +19,6 @@ import (
1919 "path/filepath"
2020 "strconv"
2121 "strings"
22- "sync"
2322 "sync/atomic"
2423
2524 "github.com/gohugoio/hugo/hugofs"
@@ -29,6 +28,7 @@ import (
2928 "github.com/gohugoio/hugo/media"
3029 "github.com/gohugoio/hugo/output"
3130 "github.com/gohugoio/hugo/related"
31+ "github.com/gohugoio/hugo/resources"
3232 "github.com/gohugoio/hugo/tpl/tplimpl"
3333 "github.com/spf13/afero"
3434
@@ -110,8 +110,7 @@ type pageState struct {
110110 * pageCommon
111111
112112 resource.Staler
113- dependencyManager identity.Manager
114- resourcesPublishInit * sync.Once
113+ dependencyManager identity.Manager
115114}
116115
117116func (p * pageState ) incrPageOutputTemplateVariation () {
@@ -522,39 +521,41 @@ func (p *pageState) initPage() error {
522521}
523522
524523func (p * pageState ) renderResources () error {
525- var initErr error
524+ for _ , r := range p . Resources () {
526525
527- p .resourcesPublishInit .Do (func () {
528- for _ , r := range p .Resources () {
529- if _ , ok := r .(page.Page ); ok {
526+ if _ , ok := r .(page.Page ); ok {
527+ if p .s .h .buildCounter .Load () == 0 {
530528 // Pages gets rendered with the owning page but we count them here.
531529 p .s .PathSpec .ProcessingStats .Incr (& p .s .PathSpec .ProcessingStats .Pages )
532- continue
533530 }
531+ continue
532+ }
534533
535- if _ , isWrapper := r .(resource.ResourceWrapper ); isWrapper {
536- // Skip resources that are wrapped.
537- // These gets published on its own.
538- continue
539- }
534+ if resources .IsPublished (r ) {
535+ continue
536+ }
540537
541- src , ok := r .(resource.Source )
542- if ! ok {
543- initErr = fmt . Errorf ( "resource %T does not support resource.Source" , r )
544- return
545- }
538+ if _ , isWrapper := r .(resource.ResourceWrapper ); isWrapper {
539+ // Skip resources that are wrapped.
540+ // These gets published on its own.
541+ continue
542+ }
546543
547- if err := src .Publish (); err != nil {
548- if ! herrors .IsNotExist (err ) {
549- p .s .Log .Errorf ("Failed to publish Resource for page %q: %s" , p .pathOrTitle (), err )
550- }
551- } else {
552- p .s .PathSpec .ProcessingStats .Incr (& p .s .PathSpec .ProcessingStats .Files )
544+ src , ok := r .(resource.Source )
545+ if ! ok {
546+ return fmt .Errorf ("resource %T does not support resource.Source" , r )
547+ }
548+
549+ if err := src .Publish (); err != nil {
550+ if ! herrors .IsNotExist (err ) {
551+ p .s .Log .Errorf ("Failed to publish Resource for page %q: %s" , p .pathOrTitle (), err )
553552 }
553+ } else {
554+ p .s .PathSpec .ProcessingStats .Incr (& p .s .PathSpec .ProcessingStats .Files )
554555 }
555- })
556+ }
556557
557- return initErr
558+ return nil
558559}
559560
560561func (p * pageState ) AlternativeOutputFormats () page.OutputFormats {
0 commit comments