frog icon indicating copy to clipboard operation
frog copied to clipboard

How to link to another post

Open cesquivias opened this issue 10 years ago • 10 comments

Is there a way to link to other blog posts? Namely, I'm looking for a way to reference other blog posts in markdown by the filename in the _src directory and have frog automatically convert them to the proper tags so they work locally (raco frog -bp) and when pushed live.

I'm sure I can take a file like 2015-01-06-blog-post.md and manually write [blog post](../../../blog-post) in a markdown file, but is there a way to have frog do that automatically? That is, I write [blog post](2015-01-06-blog-post.md) or even [blog post section](2015-01-06-blog-post.md#sub-section).

cesquivias avatar Jan 08 '15 13:01 cesquivias

This reminds me of part of issue #97, which is closed (so no worries, I wouldn't expect you to be looking through closed issues before filing a new one :)). It sounds like you want something similar to what I described in the second bullet point here?

I've been doing it manually for my own blog. I tend to write posts with a fair number of links, and nearly all are external. So it's seemed reasonable that linking to my own stuff is the same as linking to other stuff. Maybe I'd feel differently if I mostly linked to my own posts, and did so very often. Is that how you feel?

greghendershott avatar Jan 08 '15 13:01 greghendershott

I actually tried to look through the old issues, but I don't think I used the right search terms :).

Your suggestion (of having a flat directory) would simplify the linking though I guess it doesn't solve the problem. I'm guessing it would be a pain to modify the markdown parser to add this hook. Would this be more doable in scribble? A simple string-manipulating function would work, no? I've been looking for a reason to try it out.

cesquivias avatar Jan 08 '15 19:01 cesquivias

Oh, I'm sorry, I actually meant the paragraph after the second bullet, talking about a frog: URL scheme:

[Because otherwise, the only thing I can really imagine would be to let you supply URLs in your posts using (say) a frog: protocol, and Frog would replace those with the actual relative URLs during build. So e.g. frog:some-post-title would map to /posts/year/month/some-post-title.html (or whatever your permalink pattern caused the actual URL to be). But this seems like a feature that wouldn't really add much vs. what I described above. So I don't think I'm too eager to add and maintain that.]

I think this is simpler because it's independent of markdown parsing and Scribble parsing -- you still specify URLs in the usual way in both formats -- and can be handled at a later stage regardless of the source format.

To be clear, this all frog: schemes would be replaced with relative URLs, and never end up in HTML files on the real web.

greghendershott avatar Jan 08 '15 20:01 greghendershott

Ah, yeah a frog: scheme would work. It would make help disambiguate (is that a word) when the author wants to reference a blog post or the actual markdown file.

I'm not sure the proper layout of the URI. Having frog:some-post-title would be simple, but having it reference by file starting at the root of the project (e.g., frog:/_src/posts/2015-01-09-some-blog-post.md) be still simple for the user and could extend to reference other files in the future. Though that may be too much work for little benefit.

cesquivias avatar Jan 10 '15 03:01 cesquivias

Oh. Huh, with something like frog:some-post-title, I figured brevity was the main value.

Because, if I have to type

frog:/_src/posts/2015-01-09-some-blog-post.md

I'd rather just keep typing the status quo:

/blog/2015/01/some-blog-post.html

No?

greghendershott avatar Jan 10 '15 04:01 greghendershott

Oh, my main point has been to abstract away the file-renaming logic. This way an author wouldn't have to worry about how a markdown/scribble file becomes HTML and where it gets saved. Frog would take care of that. And if .frogrc is changed to save posts somewhere else the frog:<file-reference> scheme would automatically fix all references.

Brevity wasn't my top concern, but if it's possible to have both I'm all for it. That's why I think a simple filename scheme would work better so long as it isn't ambiguous what file the author is referring to. I mention the absolute filepath example to represent the other extreme: a link that would be unambiguous to frog.

On Fri, Jan 9, 2015 at 8:45 PM, Greg Hendershott [email protected] wrote:

Oh. Huh, with something like frog:some-post-title, I figured brevity was the main value.

Because, if I have to type

frog:/_src/posts/2015-01-09-some-blog-post.md

I'd rather just keep typing the status quo:

/blog/2015/01/some-blog-post.html

No?

— Reply to this email directly or view it on GitHub https://github.com/greghendershott/frog/issues/122#issuecomment-69440641 .

cesquivias avatar Jan 10 '15 06:01 cesquivias

my main point has been to abstract away the file-renaming logic

Ah I see. The thing is, it's been drilled into me that "URLs should be permanent". Once I publish something at a URL, I should strive to make it available there forever. (If necessary, I can 30x redirect elsewhere, but that original URL still reaches the resource/content.) Why? 1. Building "link equity" to increase rank with search engines. 2. Helping the web avoid bit rot.

For example, when I ported my own blog from Blogger to Frog, I set up an Amazon S3 bucket to 301 redirect all the blog.greghendershott.com/path/to/post URLs to www.greghendershott.com/path/to/post. Mainly just on principle and from habit -- not that my Blogger blog really had any equity to preserve. ;)

So I wasn't clearly hearing that point about URL-changing. Now that I am hearing it clearly, I just want to double-check -- are you sure you want to do that? :)

Seriously, I'm not sure Frog should strive to make it more convenient to cross-reference posts without using their URLs because the URLs would be changing frequently. That feels like making it more convenient to do something not-good?

greghendershott avatar Jan 10 '15 15:01 greghendershott

p.s. I feel bad this comment thread is getting long; I generally don't like debating features instead of just adding them. I'm sorry about that and I sincerely do appreciate you taking the time to make the feature request!

greghendershott avatar Jan 10 '15 15:01 greghendershott

No problem on taking a while. To be honest, writing out URLs isn't too cumbersome, but it did irk me. I wasn't sure if my proposal was just a personal preference or something others felt was in need in improvement so I'm happy to discuss it even if the feature doesn't materialize. Perhaps it's all the time writing web apps and having functions that handle URLs that makes me feel this way. I've never used a blog generator so I don't know the normal customs.

To answer your question. I'm not sure if it's what I really want. From where I come from I saw references to other blog posts analogous to wiki-style links, a quick handle while writing but will get magically converted for you once it's processed. When I want to reference another blog post I don't see it as a URL at the time. I see it more as an internal handle that will be serialized properly to HTML when the time is right. That may just be me and my over-exposure to web frameworks.

cesquivias avatar Jan 11 '15 00:01 cesquivias

I can definitely see the expectation that wiki style links might be how it could work.

I think right now this feels like it would be solving a problem that I don't have in my personal use of Frog. And I guess I'm trying to rationalize that it shouldn't be a big problem for you, either. Because I'm a little worried about the cost of adding this. And I'm just really busy at the moment with other open-source projects, too.

So: I'm going to leave this issue open, because I don't feel like it's a bad idea just because I personally don't need it. But realistically I don't think I'm going to be able to tackle this in the near future. If in the meantime anyone were to submit at PR and it didn't look too hairy, of course I'd gladly take that.

Thanks again for suggesting this! It's a great idea. I'm sorry for not acting on it now.

greghendershott avatar Jan 12 '15 02:01 greghendershott