<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sufiyan Yasa</title>
    <description>The latest articles on DEV Community by Sufiyan Yasa (@sufiyanyasa).</description>
    <link>https://dev.to/sufiyanyasa</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F401557%2Fef6a8e4b-b83c-44a3-8616-5bc8e60b2ad5.jpeg</url>
      <title>DEV Community: Sufiyan Yasa</title>
      <link>https://dev.to/sufiyanyasa</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sufiyanyasa"/>
    <language>en</language>
    <item>
      <title>Git: How to save your changes temporarily</title>
      <dc:creator>Sufiyan Yasa</dc:creator>
      <pubDate>Sat, 29 Aug 2020 17:44:29 +0000</pubDate>
      <link>https://dev.to/sufiyanyasa/git-how-to-save-your-changes-temporarily-b5l</link>
      <guid>https://dev.to/sufiyanyasa/git-how-to-save-your-changes-temporarily-b5l</guid>
      <description>&lt;h2&gt;
  
  
  "Fixed". Please pull master...
&lt;/h2&gt;

&lt;p&gt;This scenario should be very familiar to you.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"You are coding an important feature. &lt;br&gt;&lt;br&gt;
Git status reveals a large number of uncommitted&lt;br&gt;
changes.&lt;br&gt;&lt;br&gt;
As you test your feature, the app reports a nasty crash/bug/assertion on a&lt;br&gt;
different module. As you are blocked from testing, you reach out to the owner. &lt;br&gt;&lt;br&gt;
The code owner informs you that he pushed a fix a few moments ago."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you have worked in a team environment, you should at least once experienced the scenario above.&lt;br&gt;
I definitely have, especially working on a codebase with 1000 or more daily commits ( we use git as our version control ).&lt;/p&gt;

&lt;p&gt;Well, what would you do? The most common step is to pull master to retrieve the fix.&lt;br&gt;
So, you run back to your desk, and execute &lt;code&gt;git pull --rebase&lt;/code&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I am a fan of git rebase. I think that using rebase makes git history so much cleaner and easier to maintain.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Instead of getting a list of file changes or commits, your terminal reports this error:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;❯ git pull
error: cannot pull with rebase: You have unstaged changes.
error: please commit or stash them.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Translation: &lt;strong&gt;"You still have work in progress and I don't want to mess up and overwrite&lt;br&gt;
your changes. Please commit or temporarily shelve your work."&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Since you have uncommitted changes, you can't pull from master.&lt;br&gt;
You could commit your changes and move on.&lt;/p&gt;

&lt;p&gt;Emphasizing the word: &lt;strong&gt;commit&lt;/strong&gt;  - I personally think every commit should&lt;br&gt;
be workable, compilable and maintainable code&lt;br&gt;
( else I would rename &lt;code&gt;git commit&lt;/code&gt; to &lt;code&gt;git save&lt;/code&gt; )&lt;/p&gt;

&lt;p&gt;Back to our problem - there is an easier way.&lt;/p&gt;
&lt;h2&gt;
  
  
  How to pull changes while having uncommitted changes?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use Git Stash command&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Git Stash excels in these types of scenarios&lt;br&gt;
(where you need to pull the latest code changes while not being ready to commit your&lt;br&gt;
own changes).&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git stash&lt;/code&gt; is a git command that allows you to temporarily shelve&lt;br&gt;
or put aside uncommitted changes.&lt;br&gt;
You are then free to update your local copy.&lt;br&gt;
And can immediately continue where you left off by popping your stash.&lt;/p&gt;

&lt;p&gt;Back to our scenario, I would execute git stash with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git stash &lt;span class="nt"&gt;-u&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The -u sign is optional but I find it very handy. It tells git stash to include&lt;br&gt;
new files ( git stash untracked files ).&lt;/p&gt;

&lt;p&gt;Now you're left with a clean working tree. Hopefully, &lt;code&gt;git pull --rebase&lt;/code&gt; should be able&lt;br&gt;
to work.&lt;br&gt;
To continue where you left off, use &lt;code&gt;git stash pop&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git stash pop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will pop the latest stash to your working directory.&lt;br&gt;
And that's it, you have successfully pulled master without committing your local changes&lt;br&gt;
with just 3 commands.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;git stash -u&lt;/li&gt;
&lt;li&gt;git pull --rebase&lt;/li&gt;
&lt;li&gt;git stash pop&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  Automation with "rebase.autostash"
&lt;/h2&gt;

&lt;p&gt;I don't know about you but writing 3 commands every time does get tiring.&lt;/p&gt;

&lt;p&gt;So, can "git pull" auto stash and pop pending changes? &lt;strong&gt;Yes&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;You could create a special git alias that runs all 3 commands in order.&lt;/p&gt;

&lt;p&gt;However, since &lt;a href="https://developer.atlassian.com/blog/2016/01/git-2.7-release"&gt;Git version 2.7&lt;/a&gt;,&lt;br&gt;
a new global config flag ( &lt;em&gt;rebase.autostash&lt;/em&gt; ) was introduced that automates stashing. Amazing!&lt;/p&gt;

&lt;p&gt;By default, this flag is set to false. Enable it globally by running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git config &lt;span class="nt"&gt;--global&lt;/span&gt; rebase.autostash &lt;span class="nb"&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, whenever you run &lt;code&gt;git pull --rebase&lt;/code&gt;, your local changes will automatically be stashed&lt;br&gt;
and popped back. Pretty neat.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrap up
&lt;/h2&gt;

&lt;p&gt;Git stash shines in scenarios when you're stuck between pulling master&lt;br&gt;
and having a dirty working copy&lt;br&gt;
( especially during moments when your boss comes in and demands that you fix something immediately ).&lt;/p&gt;

&lt;p&gt;Paired with &lt;code&gt;rebase.autoStash&lt;/code&gt;, my daily git experience is smooth and easy.&lt;/p&gt;

&lt;p&gt;Finally, I highly recommend visiting &lt;a href="https://git-scm.com/docs/git-stash"&gt;git-stash documentation page&lt;/a&gt;,&lt;br&gt;
if you want to know more about the different modes of git stash.&lt;/p&gt;

</description>
      <category>git</category>
    </item>
    <item>
      <title>Commit Mistake: How to untracked files in Git</title>
      <dc:creator>Sufiyan Yasa</dc:creator>
      <pubDate>Thu, 27 Aug 2020 21:02:54 +0000</pubDate>
      <link>https://dev.to/sufiyanyasa/commit-mistake-how-to-untracked-files-in-git-1bak</link>
      <guid>https://dev.to/sufiyanyasa/commit-mistake-how-to-untracked-files-in-git-1bak</guid>
      <description>&lt;h2&gt;
  
  
  My Reason to Git stop tracking file
&lt;/h2&gt;

&lt;p&gt;There are a couple of reasons to untrack a file in your git repository.&lt;br&gt;
Though my obvious reason is because of fat fingers.&lt;br&gt;
Sometimes I accidentally committed a binary file with &lt;code&gt;git add .&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Thus it is pretty handy to know how to untrack files in Git.&lt;br&gt;
Plus it is super easy.&lt;/p&gt;
&lt;h2&gt;
  
  
  Tell Git to untrack file
&lt;/h2&gt;

&lt;p&gt;Use &lt;code&gt;git rm&lt;/code&gt; to Git untrack file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git &lt;span class="nb"&gt;rm&lt;/span&gt; &lt;span class="nt"&gt;--cached&lt;/span&gt; &amp;lt;filename&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And if you need untrack more that one file, simply append the files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git &lt;span class="nb"&gt;rm&lt;/span&gt; &lt;span class="nt"&gt;--cached&lt;/span&gt; &amp;lt;filename&amp;gt;  &amp;lt;filename2&amp;gt;  &amp;lt;filename3&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both of the commands above git untrack file without deleting.&lt;br&gt;
This is because of the cached option. Removing the cached option will&lt;br&gt;
 delete it from your disk.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git &lt;span class="nb"&gt;rm&lt;/span&gt; &amp;lt;filename&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After run this command, don't forget to commit the changes. Git update on other developers&lt;br&gt;
machine will automatically remove this file&lt;/p&gt;
&lt;h2&gt;
  
  
  Tell Git untrack folder
&lt;/h2&gt;

&lt;p&gt;What about when a whole folder needs to be untracked?&lt;br&gt;
Removing a whole directory is simple too with the recursive option.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git &lt;span class="nb"&gt;rm&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="nt"&gt;--cached&lt;/span&gt; &amp;lt;folder&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  If needed, ignore the file in the future
&lt;/h2&gt;

&lt;p&gt;Optionally, once you have the file removed, you can add it to your git ignore file.&lt;br&gt;
Conveniently, this file is called gitignore.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A gitignore file is a file that tells Git which files or folders to ignore.&lt;br&gt;
Gitignore file is usually placed in the root directory of a project.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For more about gitignore - read this &lt;a href="https://www.freecodecamp.org/news/gitignore-what-is-it-and-how-to-add-to-repo/"&gt;gitignore article&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why use 'git rm' to remove a file instead of 'rm'?
&lt;/h2&gt;

&lt;p&gt;Technically they are both the same. &lt;code&gt;git rm&lt;/code&gt; does 2 commands at once:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Removing the file from index&lt;/li&gt;
&lt;li&gt;Staging the next commit with the removed file&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;rm&lt;/code&gt; only removes the file from disk. You will still the to stage and commit the deleted file.&lt;br&gt;
&lt;code&gt;git rm&lt;/code&gt; does that in one single step.&lt;/p&gt;

</description>
      <category>git</category>
    </item>
    <item>
      <title>Appstore Connect API Golang Client code</title>
      <dc:creator>Sufiyan Yasa</dc:creator>
      <pubDate>Thu, 30 Jul 2020 09:19:37 +0000</pubDate>
      <link>https://dev.to/sufiyanyasa/appstore-connect-api-golang-client-code-jbn</link>
      <guid>https://dev.to/sufiyanyasa/appstore-connect-api-golang-client-code-jbn</guid>
      <description>&lt;h2&gt;
  
  
  Apple AppStore Connect API Go client code
&lt;/h2&gt;

&lt;p&gt;Over the weekend, I was testing AppStore Connect API Client in Go.&lt;/p&gt;

&lt;p&gt;Announced on &lt;a href="https://developer.apple.com/wwdc20/"&gt;WWDC 2020&lt;/a&gt;, Apple &lt;a href="https://developer.apple.com/sample-code/app-store-connect/app-store-connect-openapi-specification.zip"&gt;published&lt;/a&gt; an OpenAPI specification for AppStore Connect API (more than 250 endpoint APIs ).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gtObnaEG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/i34mvj1gasn2uq56gtxb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gtObnaEG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/i34mvj1gasn2uq56gtxb.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With &lt;a href="https://github.com/OAI/OpenAPI-Specification/"&gt;OpenAPI&lt;/a&gt;, I can generate Go client code for AppStore Connect API.&lt;/p&gt;

&lt;p&gt;During this process, I experienced difficulties in getting the client code to work.&lt;br&gt;
I realized that I could share my generated code to save others the same trouble.&lt;/p&gt;

&lt;p&gt;You can find this Github project with the generated Go code along with instructions.&lt;br&gt;
&lt;a href="https://github.com/xr1337/appstoreconnect-openapi-go"&gt;AppstoreConnect-OpenAPI-Go&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What you will find in the Github project:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Generated Code for Go&lt;/li&gt;
&lt;li&gt;Command used to generate the client code ( in the Makefile )&lt;/li&gt;
&lt;li&gt;An example on how to use the generated code.&lt;/li&gt;
&lt;li&gt;An example on how to use Apple .p8 for JWT signing&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  External tools and dependencies used
&lt;/h2&gt;

&lt;p&gt;I used &lt;a href="https://openapi-generator.tech/"&gt;OpenAPI generator&lt;/a&gt; to generate the client code.&lt;br&gt;
&lt;a href="https://github.com/dgrijalva/jwt-go"&gt;JWT-Go&lt;/a&gt; helped with signing JWT token for testing.&lt;/p&gt;

&lt;h2&gt;
  
  
  What can you do with project
&lt;/h2&gt;

&lt;p&gt;Some examples of services that can be automated are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;User invitation automation&lt;/li&gt;
&lt;li&gt;AppStore release management&lt;/li&gt;
&lt;li&gt;Test Flight&lt;/li&gt;
&lt;li&gt;Certificate management&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hopefully the generated code will help you save time ( instead of manually coding each operation)&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;If this project is useful to you, I appreciate if you could give it a &lt;a href="https://github.com/xr1337/appstoreconnect-openapi-go"&gt;star&lt;/a&gt;.&lt;br&gt;
That would help me understand if I should invest more effort into it.&lt;br&gt;
I plan to add in the future:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;More examples&lt;/li&gt;
&lt;li&gt;Automation code generation&lt;/li&gt;
&lt;li&gt;Create tag/release&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>appstore</category>
      <category>go</category>
      <category>openapi</category>
      <category>appstoreconnect</category>
    </item>
    <item>
      <title>How to create custom URLS on Gridsome blog</title>
      <dc:creator>Sufiyan Yasa</dc:creator>
      <pubDate>Tue, 07 Jul 2020 01:54:39 +0000</pubDate>
      <link>https://dev.to/sufiyanyasa/how-to-create-custom-urls-on-gridsome-blog-1n0c</link>
      <guid>https://dev.to/sufiyanyasa/how-to-create-custom-urls-on-gridsome-blog-1n0c</guid>
      <description>&lt;h2&gt;
  
  
  Shorter URLs are better for your site
&lt;/h2&gt;

&lt;p&gt;Your URL is one of the most important aspects for your site.&lt;/p&gt;

&lt;p&gt;A great URL can help improve Search Engine Optimization (SEO) and bring more visitors to your site.&lt;br&gt;
A poorly designed URL may discourage potential visitors away.&lt;/p&gt;

&lt;p&gt;Imagine that you receive an email with 2 URLS, which one would you click?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;URL A&lt;/code&gt; - &lt;a href="http://www.somesite.com/folder1/folder2/http/jfkaliburrwweqze?sessionid=1231233&amp;amp;utm_medium=bcx"&gt;www.somesite.com/folder1/folder2/http/jfkaliburrwweqze?sessionid=1231233&amp;amp;utm_medium=bcx&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;URL B&lt;/code&gt; - &lt;a href="http://www.somesite.com/how-to-bake-cake"&gt;www.somesite.com/how-to-bake-cake&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you are like me, I would choose the &lt;code&gt;URL B&lt;/code&gt;. It is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;easier to read&lt;/li&gt;
&lt;li&gt;concise&lt;/li&gt;
&lt;li&gt;understandable&lt;/li&gt;
&lt;li&gt;likely to be shared on twitter&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;URL A&lt;/code&gt; on the other hand is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;longer&lt;/li&gt;
&lt;li&gt;confusing as it has random words that does not make sense&lt;/li&gt;
&lt;li&gt;looks spammy due to the URL parameters like &lt;code&gt;sessions=1231233&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Shorter URLs can help improve SEO
&lt;/h2&gt;

&lt;p&gt;Can shorter URLs positively impact on SEO? Yes it can.&lt;/p&gt;

&lt;p&gt;Search engines would favor URLs that consist of relevant keywords.&lt;br&gt;
This rule may not be a main criteria for SEO but there are is some correlation&lt;br&gt;
with top sites on Google search.&lt;/p&gt;

&lt;p&gt;Here is a google search for search query 'types of marketing':&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--281TbXWh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/7zjgavxapfxqtyu3h6xi.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--281TbXWh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/7zjgavxapfxqtyu3h6xi.jpg" alt="Google search of types of marketing"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can make a few observations from the image above:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;All the URLs length are &lt;em&gt;short&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;All the URLs contain the &lt;em&gt;keywords&lt;/em&gt; usually in the first 3 positions&lt;/li&gt;
&lt;li&gt;All the URLs do not URL parameters.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Give this a try on your own.&lt;/p&gt;

&lt;p&gt;Make a few searches on your keywords and observe the top 10 results on Google.&lt;br&gt;
Do they match with the observation above?&lt;/p&gt;

&lt;p&gt;Next, lets look at URLs on &lt;a href="https://gridsome.org/"&gt;GridSome&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Gridsome starters use Titles as URLs
&lt;/h2&gt;

&lt;p&gt;Gridsome is a great static generator. It is easy to start blogging with &lt;a href="https://gridsome.org/starters/"&gt;Gridsome starters&lt;/a&gt;.&lt;br&gt;
&lt;a href="https://gridsome.org/starters/"&gt;Gridsome starters&lt;/a&gt; are pre-made project templates.&lt;br&gt;
They come with pre built design, plugins and markdown generators by the community.&lt;/p&gt;

&lt;p&gt;Starters are great because they save alot of time and are a great resources&lt;br&gt;
for learning &lt;a href="https://vuejs.org/"&gt;Vue.js&lt;/a&gt;.&lt;br&gt;
This site itself was made from &lt;a href="https://gridsome.org/starters/gridsome-casper-v3-starter/"&gt;Casper v3 Grdisome starter&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Unfortunately, Gridsome starters are &lt;em&gt;rarely SEO tuned&lt;/em&gt;.&lt;br&gt;
Often, you would need to investigate and apply SEO fixes on the starter yourself.&lt;br&gt;
A common pattern in most starters are using the blog titles as URLs.&lt;/p&gt;

&lt;p&gt;As an example, a blog with the following title&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;how to bake a cookie without using an oven&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;would be automatically linked to the following URL&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="http://www.abc.com/how-to-bake-a-cookie-without-using-an-oven/"&gt;www.abc.com/how-to-bake-a-cookie-without-using-an-oven/&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This is very convenient. But this convenience comes with the following drawbacks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A long title will make your URLS longer&lt;/li&gt;
&lt;li&gt;Difficult to add important keyworrds in the first 3 positions of the URL&lt;/li&gt;
&lt;li&gt;Upgrading your title will change your URL. Users that bookmark your previous URLs will receive a 404.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Titles are important for SEO. However, they are not great for generating URLs.&lt;br&gt;
Thus blog titles and URLS should be separated.&lt;/p&gt;

&lt;p&gt;Lets look at how to apply this to Gridsome.&lt;/p&gt;


  &lt;p&gt;Disclaimer&lt;/p&gt;
  &lt;p&gt;Not all Gridsome projects are built the same way.
Depending on your setup - the instructions in this article
may not apply.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to define a custom URL for your blog
&lt;/h2&gt;

&lt;p&gt;For the instructions below, I am applying changes to this &lt;a href="https://github.com/xr1337/custom-url-gridsome"&gt;github project&lt;/a&gt; project. For each changes applied, I will create a separate Merge request.&lt;/p&gt;

&lt;p&gt;Open gridsome.config.j and look for the template section.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//In gridsome.config.js
templates: {
  Blog: [{
    path: '/blog/:title'
  }],
  Category: [{
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The template section is used to create the pages (ie blog post ) for Gridsome.&lt;br&gt;
Current each post if mapped to &lt;code&gt;blog/:title&lt;/code&gt;&lt;br&gt;
Lets change that to &lt;code&gt;blog/:url&lt;/code&gt; instead.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//In gridsome.config.js
templates: {
  Blog: [{
    path: '/blog/:url'
  }],
  Category: [{
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We refered to a new variable call &lt;code&gt;:url&lt;/code&gt;. Since this variable does not exist yet.&lt;br&gt;
Trying to generate our site will throw a duplicate warning as shown below:&lt;/p&gt;



&lt;p&gt;Another problem is on the development server, we only see one article instead of two!&lt;/p&gt;

&lt;p&gt;To fix this, we will need to go to every markdown file and add URL to the top.&lt;br&gt;
Since we have only one blog post, lets update that quickly.&lt;br&gt;
Open content/blog/entry1.md and add an url.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;---
title: "Troes retardat"
tags: tag1, tag2
category: Digital
excerpt: Lorem markdownum aptos pes, Inachidos caput corrumpere! Vincere ferocia arva.
created: 2019-01-10
image: ./images/josh-spires-dronenr-sQalFlXIsLs-unsplash.jpg
image_caption: Photo by Josh Spires on Unsplash
author: author1
url: first url
---
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Similarly, open content/blog/entry2.md and add another url.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;--------
title: another article
tags: tag1, tag2
category: Digital
excerpt: Lorem markdownum aptos pes, Inachidos caput corrumpere! Vincere ferocia arva.
created: 2019-01-10
image: ./images/josh-spires-dronenr-sQalFlXIsLs-unsplash.jpg
image_caption: Photo by Josh Spires on Unsplash
author: author1
url: second url
--------
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Rerun the gridsome site again. Our custom URL should be used.&lt;br&gt;
h&lt;span&gt;ttp://&lt;/span&gt;localhost:8080/blog/first-url&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--E1yVkNlF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/tpslj7qyq5igb0f9skww.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--E1yVkNlF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/tpslj7qyq5igb0f9skww.jpg" alt="custom url example"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Please check this merge request for the changes we have done so far.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/xr1337/custom-url-gridsome/pull/1"&gt;Merge request 1&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Redirecting existing traffic to new URLs
&lt;/h2&gt;

&lt;p&gt;We saw how easy it is to change our URLs.&lt;br&gt;
But we are not done yet.&lt;br&gt;
If you have existing traffic on your site, changing the urls will cause a big drop in traffic.&lt;/p&gt;

&lt;p&gt;It takes time for Google to re-index your site.&lt;br&gt;
During that time, users that click on your links will be receive a 404 (Web page not found)&lt;/p&gt;

&lt;p&gt;Thus, it is best to redirect your users to the new URL.&lt;br&gt;
To do this, we need to add a new redirect feature.&lt;/p&gt;

&lt;p&gt;We will redirect traffic from old URL to our new URL.&lt;/p&gt;

&lt;p&gt;First lets create a new vue component that handles redirect.&lt;br&gt;
Add the new file Redirect.vue in components folder.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//In src/components/Redirect.vue 
&amp;lt;page-query&amp;gt;
query Redirect ($id: ID!) {
   blog (id: $id) {
    path
  }
}
&amp;lt;/page-query&amp;gt;

&amp;lt;script&amp;gt;
export default {
  metaInfo() {
    return {
        title: `Site has moved to ${this.$page.blog.path}`,
        meta: [
            { 'http-equiv': 'refresh', content: `0; URL=${this.$page.blog.path}`}
        ],
    }
  }
}
&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This component will redirect users to our new URL via meta refresh.&lt;/p&gt;

&lt;p&gt;Back to our configuration file, add an additional section to use&lt;br&gt;
our new Redirect component.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//In gridsome.config.js
templates: {
  Blog: [
  {
    path: '/blog/:url'
  },
  {
      name: 'redirects',
      path: '/blog/:title',
      component: './src/components/Redirect.vue'
    }
  ],
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Above we are add another definition for our blog posts.&lt;br&gt;
Each blog post will have 2 URLs, where one is a redirect to our new URL.&lt;/p&gt;

&lt;p&gt;If we invoke &lt;span&gt;http://&lt;/span&gt;localhost:8080/blog/another-title should redirect&lt;br&gt;
to &lt;span&gt;http://&lt;/span&gt;localhost:8080/blog/second-url&lt;/p&gt;

&lt;p&gt;Please check this merge request for the changes we have done so far.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/xr1337/custom-url-gridsome/pull/2"&gt;Merge request 2&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Bonus: Can I use my file names for URL instead?
&lt;/h2&gt;

&lt;p&gt;Yes, you can use your filename for the URL. I don't see any&lt;br&gt;
downsides of this approach.&lt;/p&gt;

&lt;p&gt;I leave this to the readers as practice.&lt;/p&gt;

&lt;h2&gt;
  
  
  Closing
&lt;/h2&gt;

&lt;p&gt;Heres a quick recap of what we learned so far:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Understand why short custom URLs matter for SEO&lt;/li&gt;
&lt;li&gt;Identified the downside of using blog titles as URLs&lt;/li&gt;
&lt;li&gt;How to customize blog post URLs on Gridsome&lt;/li&gt;
&lt;li&gt;How to avoid losing existing traffic&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I hope that this article helped to demonstrates the benefit and approach of owning your URLs.&lt;br&gt;
Short urls can be a game changer for your site.&lt;br&gt;
If you have been struggling with SEO, short custom URLs may be worth a try.&lt;/p&gt;

&lt;p&gt;For more reading on short URLs, here is a list of very good articles to read&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://moz.com/learn/seo/url"&gt;https://moz.com/learn/seo/url&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://neilpatel.com/blog/seo-urls/"&gt;https://neilpatel.com/blog/seo-urls/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://backlinko.com/hub/seo/urls"&gt;https://backlinko.com/hub/seo/urls&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Originally posted &lt;a href="https://sufiyanyasa.com/blog/custom-url-gridsome/"&gt;here&lt;/a&gt;&lt;/p&gt;

</description>
      <category>seo</category>
      <category>development</category>
      <category>gridsome</category>
    </item>
  </channel>
</rss>
