srackham / hindsite

hindsite is a fast, lightweight static website generator.
MIT License
2 stars 2 forks source link

Page URLs #8

Closed tyeeman closed 1 week ago

tyeeman commented 1 year ago

I'm having a problem trying to create page URLs. Getting these errors -

warning: "g:\www\hindsite\content\newsletters\April-2022.md": unhygienic document URL path: "/newsletters/April-2022.html"
warning: "g:\www\hindsite\content\newsletters\April-2023.md": unhygienic document URL path: "/newsletters/April-2023.html"

How do I get a document URLs of "/newsletters/April-2022/index.html"? These are pages, not posts. I looked at the permalink info in the docs but that seems to be for posts only?

Update - OK, I'm still getting warnings but I tried 2 things.

  1. Added permalink = "/newsletters/%p/" to template/config.toml but that did nothing.
  2. Added new folder with config - template/newsletters/config.toml, and put in this permalink = "/newsletters/%p/.

Now I get pretty URLs. How come in 1. nothing happened. That's the main config and I thought it would work?

Still getting warnings with pretty URLs. Should this be happening? -

warning: "g:\www\hindsite\content\newsletters\April-2022.md": unhygienic document URL path: "/newsletters/April-2022/"
tyeeman commented 1 year ago

Now that my doc urls are now pretty after adding permalink = "/newsletters/%p/" , I have now lost my images that are in each specific month-year folder. The urls that link to my images are newsletters/imagename.jpg which does not exist. How do I get the month-year to be included in the image url like this newsletters/month-year/imagename.jpg?

Update - I ran my site using localhost and all the images show properly. It looks like my webhost Netlify is removing the final slash of my month-year pages which prevents proper image links.

On localhost here is a sample link - https://localhost/newsletters/april-2023/. Images in the april-2023 folder show correctly.

On Netlify here is the same link - https://snlhindsite.netlify.app/newsletters/april-2023. Images do not show even though they exist in the april-2023 folder.

I wonder why Netlify is removing that final slash?

Just looked into Netlify and I have pretty urls disabled there so I don't know what's going on.

Come to think of it, why hasn't this occurred before? I have another Hindsite site that works just fine. I tried to compare to see what's different but I can't seem to find it. Take a look at these two sites. Click the "April-2023" link on each site and watch what happens to the address bar url. The old site keeps a trailing slash and the images all load. The new site I'm working on now does not keep the trailing slash and images don't load. They are both on Netlify. Interesting. How to find the difference?

https://snlhindsite.netlify.app/menu/#newsletters

https://snlhind.netlify.app/newsletters/index.html

Final Update - Well, after all the above everything is working correctly. Maybe when I switched Netlify to use pretty urls and then back again, their servers had to sync to the new settings and it took a while, I don't really know. I'm still using my permalink as shown above and still getting errors during the build but I guess I should ignore them.