Configuration for custom URL format (replace the /posts/ prefix)

8 views
Skip to first unread message

oon arfiandwi

unread,
Jan 1, 2018, 12:02:15 PM1/1/18
to nikola-discuss

Hello,

I am new to Nikola,
just explore it few hours ago, and planning to migrate my existing blog to Nikola.

My previous blog using different prefix than '/posts/',
some of them use '/contents/' and some others '/articles/'.
how to achieve this dynamically on every posts rst?
I've been thinking to just remove the prefix,
but can't find it on the conf.py

Already search about it on handbook and this group,
but may be I just can't find the correct keyword.

any help?

thank you.

-- 
sincerely,
O

Chris Warrick

unread,
Jan 1, 2018, 12:25:34 PM1/1/18
to Nikola—Discuss
Set all your POSTS entries like this:
("posts/*.rst", "", "post.tmpl"),
i.e. make the second element empty. You can then create
posts/articles/foo.rst and this will end up as output/articles/foo/,
likewise for contents.

But note that your example sounds as if /contents/ were pages in
Nikola’s parlance. If those are posts, then use the above example;
otherwise, the second element of POSTS and PAGES entries can be
anything.

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

oon arfiandwi

unread,
Jan 1, 2018, 1:09:48 PM1/1/18
to nikola-discuss


On Tuesday, January 2, 2018 at 1:25:34 AM UTC+8, Chris Warrick wrote:
On 1 January 2018 at 18:02, oon arfiandwi <oon.ar...@gmail.com> wrote:
>
> Hello,
>
> I am new to Nikola,
> just explore it few hours ago, and planning to migrate my existing blog to
> Nikola.
>
> My previous blog using different prefix than '/posts/',
> some of them use '/contents/' and some others '/articles/'.
> how to achieve this dynamically on every posts rst?
> I've been thinking to just remove the prefix,
> but can't find it on the conf.py
>
> Already search about it on handbook and this group,
> but may be I just can't find the correct keyword.
>

Set all your POSTS entries like this:
    ("posts/*.rst", "", "post.tmpl"),
i.e. make the second element empty. You can then create
posts/articles/foo.rst and this will end up as output/articles/foo/,
likewise for contents.

yes, thank you for the solution.
and now I understand what did the second parameter tuple means on this discussion [1].
 

But note that your example sounds as if /contents/ were pages in
Nikola’s parlance. If those are posts, then use the above example;
otherwise, the second element of POSTS and PAGES entries can be
anything.


no, actually I use PAGES without prefix.
and since you already mention about it, so I don't need to ask about the PAGES prefix now.

thank Chris.

 
Reply all
Reply to author
Forward
0 new messages