We are all just a few minutes away from a nice and simple links page.
Why another page?
I knoooow, right? Another page. Don’t we already have a navbar and a footer, and goodness knows how many other pages. However, it is nice for making a simple navigation for sharing across the increasingly mobile web - and almost essential for Instagram. Okay, I was entirely motivated to start working on this because of Instagram, but then I saw other potential uses.
What we are creating here is just a page with a few links to key areas of your site that people are likely to want to self-direct after seeing something else about you. I’ll assume it is your Instagram feed. Just place the link for whatever you end up coding in your Instagram bio as your website. Use the same idea here to add temporary links for discounts or current blog posts, or whatever folks might be looking for. :smiley:
How to code it up
Today, I whipped this up for two sites, this one in Jekyll, and my other site using EJS and Express. Since the setup for both was pretty straightforward but very different, I will share both here.
The end result (I’ll probably keep fiddling with them) looks something like this on mobile.
Jekyll Markdown
This blog that you are reading right here is written in jekyll with markdown. To set up a clean links page, I had to create a new layout and one new page.
I needed a new layout because I did not have any existing layouts that would center everything on the page and not print the header and footer of my typical pages.
/layouts/plain.html
The markdown needs to include YAML to indicate that we are using our new plain layout, a title, link and description. I also have a nav tag that is false if the page should now show up in the main navigation. Whether or not you need that depends on how your navbar and header is already coded.
/pages/links.md
I don’t typically have css in my markdown pages, but I could not quite get the button look that I wanted without adding the css. If you use buttons more frequently in your jekyll site or plan to, this links page could go to a layout that loops over each link and creates a button instead. The exact css settings that I have here are:
EJS/HTML/Express
I maintain the Gifts Done site with EJS and HTML with Express. The code for that was a different sort of straightforward. First, create a links page. I’m using EJS with views and pages. I’ll not post the long headernonav file but it is just the head meta and the start of the body tag. For this site, I am using Bootstrap 4, so I did not setup any special styles, the links are just part of a list-group.
/views/pages/links.ejs
The thing to remember in this situation is that you can’t just create the page. You also need to add a route so that when someone goes to http://yoursite/links/ the server will know that you want to serve up the links page that you made.