Kaushal Modi is a user on mastodon.technology. You can follow them or interact with them if you have an account anywhere in the fediverse. If you don't, you can sign up here.
Kaushal Modi @kaushalmodi
Follow

@codesections I just read your post codesections.com/blog/netlify/. Interestingly I add the Netlify redirects to avoid that just recently[1] :)

I have a question though.. you mention the use of rel canonical to solve the lesser second half of the problem.. What is that second problem? Shouldn't just the redirects be enough?

Btw, I have grown to prefer netlify.toml over the _redirects, etc. cookie files; esp. for CSP rules.

[1]: gitlab.com/kaushalmodi/kaushal

· Web · 0 · 0

@kaushalmodi good question—I didn't get into these details in the post, and maybe I should have.

The `canonical` url would be helpful any time that a site might end up with duplicate generated pages. I encountered that with Netlify's deploy previews (which it can be set to generate for pull requests or with draft builds). I think it might also be an issue with past Netlify builds, but I'm not sure.

@codesections

> I encountered that with Netlify's deploy previews (which it can be set to generate for pull requests or with draft builds)

Hmm, OK. So far, I haven't encountered duplicate pages. Netlify has an inbuilt env var $DEPLOY_PRIME_URL (e.g. it would be BR--SITE.netlify.com for a BR branch) [and similar for deploy previews]. I use that as BaseURL in . So the page URLs are branches vs deploy previews vs production build are unique..

That said, I'll watch out for issues with just 301's.

@kaushalmodi also, what do you like better about using the netlify.toml file? Just that it keeps everything in one file? Or is there another advantage I don't know about?

@codesections

> Just that it keeps everything in one file?

That too, plus

> Or is there another advantage I don't know about?

The triple-quoted multi-line strings! With those, the CSP can be broken over multiple lines like this[1]. And without that, that whole CSP block would need to be written in a single line in _headers.

[1]: gitlab.com/kaushalmodi/kaushal