I need to create absolute links on a sidebar

14 views
Skip to first unread message

MAVignau

unread,
Sep 25, 2017, 11:19:55 PM9/25/17
to nikola-discuss
I need something like:
<a href="/2004/08">
so it can be used from the root "/" of my site or from another page, like an archive's

If I use:
<a href="${ month.year }/${ month.month }"
it renders
<a href="2004/08">

If I use this:
<a href=" ${rel_link(permalink,'//{}//{}'.format(month.year,month.month)) }">
it renders
<a href="http://2004//08">

If I just use
<a href=" ${rel_link(permalink,'/{}/{}'.format(month.year,month.month)) }"
it renders
<a href="08">

So I dont't understand the logic

Chris Warrick

unread,
Sep 26, 2017, 5:08:21 AM9/26/17
to Nikola—Discuss
Nikola automatically changes all links to be relative to the current
file. This will work:

<a href="/${ month.year }/${ month.month }">

You will get "2004/08" in index.html and "../2004/08" in posts/hello.html.

If you don’t want this behavior, you can change the URL_TYPE setting,
or do a one-time override via magic links:

<a href="link:///2004/08">

Which will produce "/2004/08" no matter where the output is.

--
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16

MAVignau

unread,
Sep 26, 2017, 4:31:37 PM9/26/17
to nikola-discuss
It works!
Thank you
Reply all
Reply to author
Forward
0 new messages