How do I link a page in a template? [closed]
If there is a basic page with the route '/about', how can I link it in a template file?
<a href="{{ What goes here? }}"></a>
theming
closed as unclear what you're asking by leymannx, Shawn Conn, DRUPWAY, mradcliffe, iStryker Jan 7 at 19:04
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
If there is a basic page with the route '/about', how can I link it in a template file?
<a href="{{ What goes here? }}"></a>
theming
closed as unclear what you're asking by leymannx, Shawn Conn, DRUPWAY, mradcliffe, iStryker Jan 7 at 19:04
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
<a href="/about"></a>
– leymannx
Dec 27 '18 at 6:15
add a comment |
If there is a basic page with the route '/about', how can I link it in a template file?
<a href="{{ What goes here? }}"></a>
theming
If there is a basic page with the route '/about', how can I link it in a template file?
<a href="{{ What goes here? }}"></a>
theming
theming
edited Dec 27 '18 at 7:49
kiamlaluno♦
80.6k9132249
80.6k9132249
asked Dec 26 '18 at 22:41
craydencrayden
1247
1247
closed as unclear what you're asking by leymannx, Shawn Conn, DRUPWAY, mradcliffe, iStryker Jan 7 at 19:04
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
closed as unclear what you're asking by leymannx, Shawn Conn, DRUPWAY, mradcliffe, iStryker Jan 7 at 19:04
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
<a href="/about"></a>
– leymannx
Dec 27 '18 at 6:15
add a comment |
<a href="/about"></a>
– leymannx
Dec 27 '18 at 6:15
<a href="/about"></a>
– leymannx
Dec 27 '18 at 6:15
<a href="/about"></a>
– leymannx
Dec 27 '18 at 6:15
add a comment |
2 Answers
2
active
oldest
votes
Let assume the page is a node whose ID is 4. You can use the following code, in a template file.
<a href="{{ path('entity.node.canonical', {'node': 4}) }}">About us</a>"
Is there no way to specify using a path based on the URL alias? Such as '/about'?
– crayden
Dec 26 '18 at 23:10
1
@crayden What if a month from now someone decides to change it to /about-us? What do you think will happen if the alias changes?
– No Sssweat
Dec 27 '18 at 0:24
@crayden in the case above,path()
will automatically get the URL, the alias if there is one, based on the node id.
– No Sssweat
Dec 30 '18 at 1:55
add a comment |
You can use the path function to call specific routes
<a href="{{ path('user.register') }}">My link</a>
Or of course, you can do it the old-fashioned way
<a href="/about">My link</a>
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Let assume the page is a node whose ID is 4. You can use the following code, in a template file.
<a href="{{ path('entity.node.canonical', {'node': 4}) }}">About us</a>"
Is there no way to specify using a path based on the URL alias? Such as '/about'?
– crayden
Dec 26 '18 at 23:10
1
@crayden What if a month from now someone decides to change it to /about-us? What do you think will happen if the alias changes?
– No Sssweat
Dec 27 '18 at 0:24
@crayden in the case above,path()
will automatically get the URL, the alias if there is one, based on the node id.
– No Sssweat
Dec 30 '18 at 1:55
add a comment |
Let assume the page is a node whose ID is 4. You can use the following code, in a template file.
<a href="{{ path('entity.node.canonical', {'node': 4}) }}">About us</a>"
Is there no way to specify using a path based on the URL alias? Such as '/about'?
– crayden
Dec 26 '18 at 23:10
1
@crayden What if a month from now someone decides to change it to /about-us? What do you think will happen if the alias changes?
– No Sssweat
Dec 27 '18 at 0:24
@crayden in the case above,path()
will automatically get the URL, the alias if there is one, based on the node id.
– No Sssweat
Dec 30 '18 at 1:55
add a comment |
Let assume the page is a node whose ID is 4. You can use the following code, in a template file.
<a href="{{ path('entity.node.canonical', {'node': 4}) }}">About us</a>"
Let assume the page is a node whose ID is 4. You can use the following code, in a template file.
<a href="{{ path('entity.node.canonical', {'node': 4}) }}">About us</a>"
edited Dec 27 '18 at 7:51
kiamlaluno♦
80.6k9132249
80.6k9132249
answered Dec 26 '18 at 23:05
MiharbKHMiharbKH
3127
3127
Is there no way to specify using a path based on the URL alias? Such as '/about'?
– crayden
Dec 26 '18 at 23:10
1
@crayden What if a month from now someone decides to change it to /about-us? What do you think will happen if the alias changes?
– No Sssweat
Dec 27 '18 at 0:24
@crayden in the case above,path()
will automatically get the URL, the alias if there is one, based on the node id.
– No Sssweat
Dec 30 '18 at 1:55
add a comment |
Is there no way to specify using a path based on the URL alias? Such as '/about'?
– crayden
Dec 26 '18 at 23:10
1
@crayden What if a month from now someone decides to change it to /about-us? What do you think will happen if the alias changes?
– No Sssweat
Dec 27 '18 at 0:24
@crayden in the case above,path()
will automatically get the URL, the alias if there is one, based on the node id.
– No Sssweat
Dec 30 '18 at 1:55
Is there no way to specify using a path based on the URL alias? Such as '/about'?
– crayden
Dec 26 '18 at 23:10
Is there no way to specify using a path based on the URL alias? Such as '/about'?
– crayden
Dec 26 '18 at 23:10
1
1
@crayden What if a month from now someone decides to change it to /about-us? What do you think will happen if the alias changes?
– No Sssweat
Dec 27 '18 at 0:24
@crayden What if a month from now someone decides to change it to /about-us? What do you think will happen if the alias changes?
– No Sssweat
Dec 27 '18 at 0:24
@crayden in the case above,
path()
will automatically get the URL, the alias if there is one, based on the node id.– No Sssweat
Dec 30 '18 at 1:55
@crayden in the case above,
path()
will automatically get the URL, the alias if there is one, based on the node id.– No Sssweat
Dec 30 '18 at 1:55
add a comment |
You can use the path function to call specific routes
<a href="{{ path('user.register') }}">My link</a>
Or of course, you can do it the old-fashioned way
<a href="/about">My link</a>
add a comment |
You can use the path function to call specific routes
<a href="{{ path('user.register') }}">My link</a>
Or of course, you can do it the old-fashioned way
<a href="/about">My link</a>
add a comment |
You can use the path function to call specific routes
<a href="{{ path('user.register') }}">My link</a>
Or of course, you can do it the old-fashioned way
<a href="/about">My link</a>
You can use the path function to call specific routes
<a href="{{ path('user.register') }}">My link</a>
Or of course, you can do it the old-fashioned way
<a href="/about">My link</a>
answered Dec 26 '18 at 22:56
100pic100pic
46328
46328
add a comment |
add a comment |
<a href="/about"></a>
– leymannx
Dec 27 '18 at 6:15