 All right, what's up everyone? So in this video I want to talk about the short little script that I use to create a blog on my website I've talked about this before when I wrote it around a year or so ago But it's way better than it was back then and I've been getting it getting a lot of questions about it recently So just before I even go into it. You can get it on my github. It's just Luke Smith X Y Z slash LB There's only one file you need. It's this LB What does LB stand for? I don't know Luke's blog. Maybe less bloated. It doesn't really stand for anything in particular But you can download that script and if you look at it if you look at it, it is I mean as the github said it says it's a blog and RSS system in less than a hundred lines of shell script I think it's actually yeah, it's less than 80 now So I guess maybe that makes it better But I've added a bunch of stuff to this while simultaneously making it You know less lines of code code anyway I'll talk about what this thing actually does because that's what matters So here's my website. Now this script generates a blog But a blog that's viewable in many different ways depending on what you want So for example, you can have a blog index file that looks like this. This is generated automatically so you have all your blog posts you have You know the date they were released that's automatically added In addition to that you have a rolling blog page. This originally was the only interface of the blog But you know, it's easy enough to add everything at once So it also generates a page that looks like this Notice that you know, each of these blog posts is an individual entry Now there are links on both the blog index and this to a standalone page for each blog entry So you can click on that and all this again is automatically generated And also on the rolling blog page, you have you know links So you can either click on this link or Copy it to somewhere and someone else and the idea behind this is of course It links directly to that post in the rolling blog page And that's nice if you want to link someone to something on your blog But you'd also sort of like them to scroll up and down and see what else is on there But of course, there's more stuff in addition I don't have this link directly from my website, but if you have an Apache web server it also You know, all of the blog posts are you know stored in the blog directory and you can see them in apaches You know index directory thing this The blog script will automatically generate a Basically a an ht access file that has descriptions of all this and there's actually I don't really think of this as being a main use of the blog But there's another reason I do this that I'll I'll talk about in a second Um, and of course, I should say that all of this stuff has You know all like the the standalone blog pages And also the rolling if I go back to the rolling blog for a second Um, you'll notice that you know these entries all have custom css You can easily set your own css for all of these so if you want them to stick out You know mine puts them in sort of bubbles with you know lines on the left But you can do whatever you want now in addition to all this Something that I think is sort of most important is having an rss entry for everything So in addition to it the script automatically generating a blog it generates an rss entry for every single thing And one thing that really peeves me about some Uh rss feeds based on blogs is They don't include the entire post But in this case it does the blog the entire blog post all the text is included in the rss entry So if you want you don't have to go to my website to read my blog you can just Have the rss feed and then read whatever So that's pretty nice. And of course, you know, it validates right everything works pretty much well So let me show you so how do I do this? How does this actually work? It's pretty simple. Um, it's sort of like a static site generator, but it's probably even You don't even have templates or anything. What this script does is literally just adds HTML to particular files. So while generating the standalone pages Let me show you show you the interface of it. So if I go to my website folder Uh, and I'm gonna run I'm gonna run the lb script It'll give you directions, but I'll go ahead and run you through it. So if I want to make a new blog post I can press lb. Uh, just run the script with the in option and let's name our I will just say this is an example blog post Okay, so then it just what it then does is stores this in a drafts directory and You know, you can write anything you can write Any html In this post Okay, so when you're done, you can exit it doesn't automatically add this post to your blog You have to publish it that is run it with the p option And it'll ask you to add, you know, this is listing out all the drafts that I have in my folder And if I want to add one I can just select the number that is listed here And press enter. So now if I let me actually open up That file the blog index file and you'll see that this post now exists I haven't uploaded it to my website, but uh, you know, you can go on here You can okay, it has its own standalone page. It has all the different links required Now you can also add anything you can add an html. It's pretty straightforward Now, of course, you can also let's I mean, obviously, I don't really want this post so I can delete it with lbd And I can get rid of that by typing in its number Very simple. I can also one thing that I've added since I originally Started the blog script is an ability to revise previous Blog posts so you can type in are and it will give you already published blog posts And it'll basically copy them back to the drafts directory and you can edit them and then republish them If you made some kind of mistake or a link changed or something else That's a relatively recent addition Um, now there are a couple other things now really how this thing works aside from the post that is just automatically generated You know, whenever you Whenever you like start writing it out everything else All the other relevant metadata so to speak is actually just stored in the ht access file Now as I said a second ago, you can um, if you don't know Apache web servers have this ability to look at directories And you can list out all the files in a directory with a description Now coincidentally enough, I sort of use the ht access file As a kind of a database so if you go into This file you'll see that what I do is I really just add the name of the blog post And it's blog post it's html file and then in a comment. I include the date. It was originally published And that's just a way of having a database file So it makes it easier to I guess revise posts Originally when I first put the blog script out I had I actually put that information in the file Which is really ugly and the user can mess it up. But now what's better. So And of course when you delete a post it Uses you can check it out yourself. It will go through It will go through your rss file your blog file your index file search for the relevant Using a sed command it'll search for the relevant entry and delete that So every all of that stuff is automatic now I should say there's a you have to do a little installation to get this working Although it's super easy. I mean it shouldn't even be called installation. Actually if you run The blog script it'll tell you what to do That is be sure to have the following pattern add it to your rss feed blog file and blog index And that is this little comment. And so what this little comment does if I open up my blog index file You'll see that This little line here This this comment marks where the blog script is going to be adding new material So if I add a new You know blog blog post the in the index file It's going to add the list item of the new blog post right below this This line right here same thing in my rss feed if I go to my rss feed You have to all you have to do is put in this little line here And it will automatically add the new rss entries directly below that So to install it all you really have to do is add To the blog file whatever file you want to have the index whatever file you want to you know use as your rss And whatever file you want to use as your rolling blog page Add to them these little comments and that is where the script will add everything and that's it That's really all you have to do But there is a couple extra things a couple extra little notes people have asked me about in the In the past and I want to explain why I do them And also little perks. So First off one thing I get asked a lot about is on my main page. I have this recent blog posts Area. This is not actually automatically generated by the script. It's not a built-in feature But it's something that it's literally like two lines of code. It's super easy to do yourself Now what this is? I will go to I have a little update script that I can pull up here So this is the script that I run. It's really an rsync command that You know puts my remote or my local repository or my local website It uploads that to my remote website. That's all that does So I run this whenever I want to update my website But before that command I have these two little lines here run and what that does I'll show you what that does but really Uh, let's see. Yeah, so I grep out the sequence of list item from the blog index file and that will list out all of the all the blog entries And specifically I want the most recent five. So I'm going to say said five q Which is pretty autistic, but you know, um, and then I'm going to put them all on one line Using a translate. Okay. So all of these are now on one line, etc, etc And basically what I do is I take that sequence which is going to be the last five blog entries and I search for the A comment blog that I put on my main page And this command just replaces that line that has blog on it With a new line that says blog and then the five entries So all five of those entries if I show you the source for this Are right here Again, it just says blog and then it lists all the five entries all in one Okay, so really every so what this script is doing or what these two lines are doing Is that uh, every single time I update my website These two lines are on which will find the last five blog entries and will put them on my main page So people can see what I put up most recently So that's that's one thing another thing that I do when I first made the script I was a little worried about Like the rolling blog page becoming too big, especially if you're I don't use images in my posts But you know, sometimes I have really long blog blog entries or something. So one thing that I did actually is I divide Um, I actually use as my rolling blog page a file named 2019 or in 2018. I used 2018 And the idea behind that is every year I will switch my blog You know my blog posts just so it doesn't get too big and what I can do is I actually link blog html To whatever year it is now. So um now blog html is not set in the blog file In lb lb is going to add stuff to 2019 But if everyone anyone goes to luke smith.xyz slash blog dot html It will automatically link to whatever year it is And that's just to make things a little easier for the user, but also keep permalinks Correct. So I'm not actually moving things around. So that's why I do that If you're not putting up that many blog posts, you might not have to worry about it But I wanted to be extra cautious when I started Um, and let's see one other thing that I don't have done automatically Mainly because I don't necessarily want it to be a set feature is on the blog index file Um, you'll notice that there are month Title or head headings here. These are not added automatically every month I will manually add it and I'll manually move the comment After which you put New blog entries And that's just because you know, I don't it's it'd be a little more difficult to have the script Do that automatically and there might be a lot of people who Just want the list entries and you know, nothing else don't don't want any of these fancy headers So I don't want to enforce that every on everyone Um, so anyway So that's about it. I encourage you again check it out. I'll put the link to it in the description It's just on github luke smith xyz slash lb Um, if you have any Suggest oh, there are other things other little changes I've added in like better Um, you know urls and stuff like that. It used to be really messy, but um I encourage you to check it out. Just play around with it I know I get emails from people all the time who say wow, this thing's great I found it and I really enjoy it. So I just wanted to do this video making sure that everyone else knows about it So, uh, anyway, thank you and I will see you guys in the next video