Blog

Kentico Tip: Tilde your references

by Joel Dahlin on January 19, 2015

Kentico Tip: Tilde your references

I've often worked on sites that were in development in a subdirectory, ie www.mydomain.com/myapp. Too often I see developers using the path /myapp/[some path] to refrence their objects. It works fine when viewing in the sub-directory but then when they go live they realize everything is broken.

I also on the other hand have seen devs simply use the leading / to reference their objects. This works if you're running the site on the top level and the majority of the time you won't run into any issues. However, thsi has caused issues in a couple of scenarios. Let's say some day down the road the company has a couple of sites they decide they want to merge under one domain and then /app1, /app2. Well now all these references will need to be updated with a leading ~/. The other scenario that i've seen is, lets say I want to work on a site locally. I often will run these sites under a sub-directory like kentico.local/[App I am working on]. This way I can re-use a license that I already have instead of having to wait on the client to retreive a new one. If the site was built using ~/'s for refrences there aren't any issues.

It's just best practices to use the ~/, it doesn't hurt anything so you might as well.

#tip

Comments
Blog post currently doesn't have any comments.
 Security code