13

I tried to link with the html file name, but it works because they are on the same folder.

[Title](./this-is-the-file.html)

But it is possible that another article would appear on another folder because of the ARTICLE_URL pattern. Examples:

[Title 1](/2014/02/article1.html)
[Title 2](/2014/01/25/article2.html)

Is it possible to link your own articles with a reference to the slug ? Any other better solution than the generated HTML file name ?

hjpotter92
  • 78,589
  • 36
  • 144
  • 183
jordiburgos
  • 5,964
  • 4
  • 46
  • 80
  • 2
    I don't think there is a easy way to do this for now. Wish someone would create a plugin for this. – mawenbao Feb 21 '14 at 09:25

3 Answers3

18

As noted in the documentation, you can link to other source content files via:

[a link relative to content root]({filename}/this-is-the-source-file.md)

... or ...

[a link relative to current file]({filename}../this-is-the-source-file.md)

Pelican will incorporate your chosen URL scheme and automatically determine the proper way to link to the other article.

kmonsoor
  • 7,600
  • 7
  • 41
  • 55
Justin Mayer
  • 2,063
  • 11
  • 15
  • 2
    This works the same way when writing in reStructuredText instead of Markdown: ```This is `a link <{filename}/somefile.rst`_ to somewhere else.``` – Snorfalorpagus Nov 10 '15 at 22:45
3

The way I do this is by specifying my own sluglines using the save_as metadata tag. So if I have a blog post called my_post.md, it'll look like this:

Title: My Blog Post
save_as: myblogpost.html

This is the world's most boring blog post.

That ensures I can link to it at /myblogpost.html. Then in some other blog post, I can say:

Title: My Second Blog Post
save_as: mysecondblogpost.html

This is the world's second most boring blog post. The most boring blog post is [here]({{ SITEURL }}/myblogpost.html).

It's a more flexible and elegant solution that gives you finer-grained control. And if you're not using Pelican for a blog site, it's pretty essential.

charlesreid1
  • 4,360
  • 4
  • 30
  • 52
  • 1
    Are you sure you can use SITEURL in the content ? I can use it only in the templates otherwise I get ``WARNING: Replacement Indicator '{ SITEURL ' not recognized, skipping replacement`` – Pierre Jul 28 '18 at 10:32
0

To deal with link in rst / restructured text.

Say you want to have link from your second post to first. Here is piece of context from that second post:

If you wish to see my first blog post click `here`_

.. _here: first-blog-post

And first blog post should have proper slug:

First blog post
########################################
:date: 2019-02-18 20:31
:category: entry
:tags: python, blog, first
:slug: first-blog-post

I have configuration:

ARTICLE_URL = '{date:%Y}/{date:%m}/{slug}.html'

and it deals with additional stuff like year, and month. Most probably you can stick with slug instead of having to track HTMLs.

Michał Zaborowski
  • 3,911
  • 2
  • 19
  • 39