statamic / ssg

The official Statamic Static Site Generator
234 stars 24 forks source link

URL segments leaking from a generated file to the next ones #38

Closed mvolpato closed 3 years ago

mvolpato commented 3 years ago

I have a website that I just migrated from Statamic 2 to Statamic 3 and I am trying to generate a static version of it. The css classes of body depend on the segments of the URL.

In layout.antlers.html:

...
<body class="template-{{ template }} page-{{ if segment_1 }}{{ segment_1 }}{{ else }}home{{ endif }}{{if segment_2}}-{{ segment_2 }}{{endif}}">
...

The website works well, before generating static code:

In the generated website:

Notice the extra -retail in the class attribute.

In the logs I can see that subscribed and work are generated right after solutions/retail, so my guess is that segment_2 has leaked to the next pages:

[✔] /solutions/retail
[✔] /subscribed
[✔] /work
mvolpato commented 3 years ago

On a similar note, I am using multiple sites. My secondary site is in a subfolder sitename.com/en. The en is evaluated in antlers as segment_1.

For instance

This is instead correct in the dynamic version of the website.

I am not sure this is related to the issue above. Let me know if not, I will create a new issue.

mvolpato commented 3 years ago

Update:

{{ current_uri | segment:X }} seems to work, so I use now {{ current_uri | segment:2 }} instead of {{ segment_2 }}.

About the multisite part, I am not even trying before this other issue is fixed, because without that issue fixed multisite does not work at all.