I'm trying out Umbraco 7.2.4 and would like to know the best way to link to another page on my site from a template. In 4 and 6 I could do something like <a href="/{local Link:1234}"> (no space) and it'd link to the page with that ID, maintaining the link automatically as the page is moved or renamed. However, in 7, that doesn't work; it just copies the HTML verbatim instead of linking to the right page.
I haven't been able to find any documentation around how to accomplish this in 7. Naturally I don't want to use the actual URL in case the target page is moved. What's the best way to do this?
Preferred way to link to a page from template?
Hi,
I'm trying out Umbraco 7.2.4 and would like to know the best way to link to another page on my site from a template. In 4 and 6 I could do something like <a href="/{local Link:1234}"> (no space) and it'd link to the page with that ID, maintaining the link automatically as the page is moved or renamed. However, in 7, that doesn't work; it just copies the HTML verbatim instead of linking to the right page.
I haven't been able to find any documentation around how to accomplish this in 7. Naturally I don't want to use the actual URL in case the target page is moved. What's the best way to do this?
Thanks :)
Hi Chris,
The way you can do it is to use one of the Umbraco helpsers https://our.umbraco.org/DOCUMENTATION/Reference/Querying/UmbracoHelper/,
To do it in the dynamic Razor you could use:
For the strongly typed Razor you can use.
Hope this helps,
/Dennis
If you only want the URL you could use the NiceUrl method
Jeavon
Yes, NiceUrl works. Thanks for that. Going from 6 to 7 is proving "interesting"! :)
is working on a reply...