Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Similar or "You might be interested" posts #74

Open
zshamrock opened this issue Jul 29, 2015 · 12 comments
Open

Similar or "You might be interested" posts #74

zshamrock opened this issue Jul 29, 2015 · 12 comments

Comments

@zshamrock
Copy link

This is a nice feature of the blog engine to provide set of articles in the end of the post linking to similar/"you might also like" posts.

One way to implement this might be to add 2 extra metadata into post header, in addition to :title, :layout and others:

  1. :id - an id/alias of the current post, like :id :clojure-intro (so, easily memorizable for the blog owner, and used only internally instead of relying on the post file name or title, which might be changed separately from the :id)
  2. :similar-posts <vector of id-s>, like :similar-posts [:clojure-intro :value-simplicity], etc. So, the author decides himself what other articles related to this one, and which might be interested for the reader as well.

And then update the page template to iterate over :similar-posts if it is not empty, to put set of links on the bottom or somewhere else recommending further reading.

@himmAllRight
Copy link
Contributor

An automatic implementation could just be randomly selecting 0-2 posts from the tags that the post is made with. This option could be selected with a :similar-posts option in the post header also, but it would auto generate the similar posts, rather than having to manually set them.

This could also be combined with zshamrock's idea where if you supply a vector of :ids to the :similar-posts header option, it can use them. If a general True is supplied, it auto selects using the tag method, and if False or the option isn't specified, it doesn't add suggest posts at the bottom of the post.

@hantuzun
Copy link
Contributor

Having :id metadata would be very helpful for this and future features.

I'd like Cryogen to have an automated implementation of showing similar posts. Asking authors to determine similar posts could become a hassle for them.

TF-IDF algorithm is one of our best options for determining similar blog posts. Similarities could be calculated and :similar-posts vector could be inserted during static site generation.

I'd like to work on this issue!

@lacarmen
Copy link
Member

I agree that an automated implementation would be best for this feature. My original concern with this was that user generated :id's would get too fiddly.

I'd like to work on this issue!

@hantuzun please go ahead! And feel free to reach out to me if you have questions :)

@hantuzun
Copy link
Contributor

@lacarmen, with pleasure.

Could we discuss how can we generate :ids from posts? Can we depend on post creation dates? Let's open another issue for that.

@lacarmen
Copy link
Member

@hantuzun I don't think creation dates should be used since those may not necessarily be unique. Another way to generate :id's could be by hashing the file names of the posts.

@tjungbauer
Copy link

Hello, I think a simple ":group" metadata would help already, that way I can define a group of posts manually. My idea would be to add it like tags, but while tags is a list of keywords, the group is just a link to one (maybe more) group.

For example: I have written several tutorials about a specific topic: these I would like to group

Unfortuantely, I did not fully understand the customization which are possible. for example I tried to add the "tags count". that worked, but as soon as I change something (i.e. add a space in tags.html), the count number disappeared again.

@lacarmen
Copy link
Member

@tjungbauer good thinking using the extension capabilities. What part did you get tripped up on? The two extension functions basically allow you to manipulate the post/site data (adding keys, changing values, etc. Anything you want really) before passing it to the render functions.

Can you be more specific about the problem you ran into with the tags example? Adding a space to the HTML template should not break things.

@tjungbauer
Copy link

@lacarmen I try to follow this guide: http://cryogenweb.org/docs/customizing-cryogen.html#add_counts_of_tag_occurrences

I created the file compiler.clj under src/cryogen and copied the code into it. I also changed the tags.html. Today nothing is shown, when I "ring" the server

I have checked everything in at https://github.com/stderrat/blog-src maybe it is obvious what does not work. for me clojure is kinda new. :)

@lacarmen
Copy link
Member

@tjungbauer oh I see :)

The example code should be placed here and here. The first is called when you run lein ring server and the second is called when you run lein run (compile once for deployment.

If you do not want the code duplicated then put the code into a function your new file, compiler.clj (which needs to be made into a proper namespace) and import that into server.clj and core.clj. Here's an example.

@tjungbauer
Copy link

ahhh, now I get it. sorry for that. I'll try to add this "group" metatag then.

many thanks for your help.

@lacarmen
Copy link
Member

Excellent, hope it works!

@holyjak
Copy link
Contributor

holyjak commented Oct 5, 2021

IMO introducing an extra :id just complicates the code. The filename is the id. And yes, you might decide to change that. Simple search & replace is a good enough solution for me.

As suggested, you can use the extend-params-fn to add any custom/dervied data visible to the templates - f.ex. to compute a map of article file name -> related articles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants