Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
A few days ago I shared my personal Zoom room link to a few people: https://www.harsh17.in/zoom. The neatness of this in comparison to something like https://zoom.us/j/99672273048?pwd=eXV5R2pBR0FqNlBUWmtLdCt6THl3dz09 was amazing. It had two immediate effects:
- Sharing Zoom link wasn’t a tedious task anymore. I could type it anywhere from my memory.
- People started taking my Zoom calls more seriously. I’d like to believe it was due to my content but the short URL certainly had an effect.
How did I do it?
R is amazing and can easily be extended to new functionalities. Blogdown is an R package for creating personal websites.
You can create your own set of URL redirects in Blogdown. Instead of typing long URLs, you can create your own custom short URLs of the form yourwebsite.com/shorturl
.
Step 1 < svg class="anchor-symbol" aria-hidden="true" height="26" width="26" viewBox="0 0 22 22" xmlns="http://www.w3.org/2000/svg"> < path d="M0 0h24v24H0z" fill="currentColor"> < path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76.0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71.0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71.0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76.0 5-2.24 5-5s-2.24-5-5-5z">
Go to your folder /static/
located in your personal website folder. It may or may not have any content already. If you do not have that folder, create one right beside other folders such as content
, layout
and themes
.
Personal website directory. Create a folder
static
here if you don’t have it already.
Step 2 < svg class="anchor-symbol" aria-hidden="true" height="26" width="26" viewBox="0 0 22 22" xmlns="http://www.w3.org/2000/svg"> < path d="M0 0h24v24H0z" fill="currentColor"> < path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76.0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71.0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71.0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76.0 5-2.24 5-5s-2.24-5-5-5z">
Open your text editor (Notepad in Windows and TextEdit in MacOS) and create a new file named _redirects
with no extension. Your computer will tell you add an extension, ignore the warning and go ahead.
Step 3 < svg class="anchor-symbol" aria-hidden="true" height="26" width="26" viewBox="0 0 22 22" xmlns="http://www.w3.org/2000/svg"> < path d="M0 0h24v24H0z" fill="currentColor"> < path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76.0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71.0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71.0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76.0 5-2.24 5-5s-2.24-5-5-5z">
Write your URLs there. Start with the short URL and then long URL with at least two tab spaces. See my example below.
Remember to leave appropriate space (at least two tabs) between the short and long URLs. Handle ‘
/
’ properly.
You can have comments starting with #
.
That’s all!
Commit your edits to Github and give it two minutes to deploy via Netlify. Try your short URL and it should work.
Some Tips
Create short URLs for articles or website you frequently share or visit. For example, I have created short URLs for my social media profiles because twitter.com would take me to the home page instead of profile page.
Create a short URL for your Zoom room link. This one is a no-brainer.
Create short URLs for content you share often. I frequently share link to my Newsletter and my article on IPM admissions. So, I created their short URLs that I can type as I go.
Troubleshooting
Here are some tips in case you run into some troubles.
-
Make sure you leave at least two tab spaces between short URL and long URL.
-
/
matter. See that you are using the right short URL with or without/
at the end. -
Commit to Github and wait for results. Netlify takes a few minutes to deploy your new site.
If you still have troubles, write to me at hello@harsh17.in and we can resolve it together.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.