ssg icon indicating copy to clipboard operation
ssg copied to clipboard

Per-site views failing to be considered when using SSG

Open davebarrau opened this issue 2 years ago • 1 comments

The Multi-Site docs state that you can arrange your directory structure so that if resources/views/<site name>/ exists, it will preference that over resources/views/.

This currently works in statamic/cms for the control panel + anything web-based, but not for ssg:generate for me (using statamic/cms:v3.4.4 and statamic/ssg:1.3.0).

I believe this may have been a regression when https://github.com/statamic/cms/commit/01cc304545a60850d5df16cbe05e2dd9d6b38f02 was introduced, as that commit moved addViewPaths() to a web middleware and removed the call from DataResponse::toResponse(). I believe ssg:generate uses DataResponse::toResponse() (via Page::write()) but does nothing with this new middleware, which means the per-site view path is not set correctly when using the static site generator.

Adding ->addViewPaths() back in to DataResponse::toResponse() ~~fixes it for me~~ (edit: scratch that, it reintroduces the exponential loop issue that was previously fixed), but I'm not sure if it was removed for a reason (perhaps to fix another bug?).

davebarrau avatar Feb 20 '23 07:02 davebarrau

Closed #128 in favour of this issue.

I’ll copy what I experienced from that issue into this comment.

  • Run SSG generate and see that site1 and site2 will use the override of site1
  • Run SSG generate again and you may see that the overrides aren't used, both site1 and site2 will fallback to resources/views/home.antlers.html instead of the site override

michaelr0 avatar Mar 15 '23 11:03 michaelr0