TheLettuceMaster
TheLettuceMaster

Reputation: 15734

Using the correct href path in a Twig template

I have this link in my Twig template:

<li><a href="categories/{{ category.id }}">{{ category.category }}</a></li>

On the first page load, it loads as expected. For example:

<li><a href="categories/10">Music</a></li>

When I click on this link, it keep adding this to the url. For example, if I clicked on it 3 times, I get:

http://localhost:8080/myApp/categories/categories/categories/10

How can I get the correct path instead of just keeping adding to it? Is this a Twig parameter I should be using?

Upvotes: 0

Views: 2159

Answers (1)

SajeshBahing
SajeshBahing

Reputation: 77

I think it's because you have given relative URI instead of absolute one.

try giving your base URI before categories

<li><a href="{{ YOUR_BASE_URI }}/categories/{{ category.id }}"

Upvotes: 2

Related Questions