How to fix URL locale error for second language in my site?

Hello,

I am adding a second language for my site and the problem is

DEFAULT LANGUAGE → Error

{{ routes.root_url}}/pages/guide => //pages/guide

ENGLISH LANGUAGE → OK
{{ routes.root_url}}/pages/guide’ => /en/pages/guide

any tag to fix this or do I need to do a if else to fix this

{% liquid
if routes.root_url == ‘/’
assign base = ‘’
else
assign base = routes.root_url
endif
%}

{{base}}/pages/guide

This is my current fix but is there a better one?

try: {{ pages[‘guide’].url }}