Sitecore – Shortening URL (for Your SEO Sake)


Hello, all! Tonight seems like the time for me to unleash what I have discovered during my time of blogging-hibernation. Earlier, I talked about WURFL and sitecore’s default way to detect device, now I talk about the way to shorten URL in Sitecore. This way bug me off and I left my question in stackoverflow left unanswered.

I am really aware that there is a default way for Sitecore to perform such task. What I found is my URL is really long and my boss is quite angry for it mess the SEO. Below is the default way.

UrlOptions opt = (UrlOptions)UrlOptions.DefaultOptions.Clone();
opt.SiteResolving = Sitecore.Configuration.Settings.Rendering.SiteResolving;
linkToResep.NavigateUrl = LinkManager.GetItemUrl(citem, opt);

Now, as you see, you need to configure the config too. So that it will shorten the URL as you wish. You can look on my question for detail.

I got various answers from kind people in my question, but, I still having trouble in it. So I am enlightened when my boss said that in PHP we can regex match something. Well, yeah! I will use regex to remove those long link!

As default we know that Sitecore LinkManager will produce a long link that contains /sitecore/content/sites/yoursite/ to access your items. Well, it seem so suck to the SEO. Then we should remove it. Below is how.

  1. Create a link using Sitecore.Links.LinkManager.GetItemURL(myItem). The output will be used as a parameter to my method that will shorten the url.
  2. Create a method that will receive a link and will shorten it for sure. I suggest you to create a helper class that will contain all functions and helpful methods that you need in many classes.
    public static string ShortenURL(string URLToShorten)
    {
        return Regex.Replace(URLToShorten,@"sitecore/content/sites/[\w]{1,}/","");
    }
    
  3. The call will be like below.
    yourHyperLinkObject.NavigateUrl = your.helper.ShortenURL(Sitecore.Links.LinkManager.GetItemURL(myItem));
    

Well, I tested it already, and thank you to the regexpal that ease my testing.

Wait, wait, wait, wait. Hold on! That easy? Yes. Why I didn’t find it out so quickly? Well, people, I didn’t think out of the box. I was when I found this out through my boss’ words about PHP. Okay, problem solved? Not yet! Look on the title, for your SEO sake. We just shorten the URL and not finished optimizing the SEO.

If you are Sitecore developer, then you must have known that you can access your site using both yourdomain.com/sitecore/content/sites/yoursitename/youritemname and yourdomain.com/youritemname. Okay, you knew it already, then what about it. As soon as I can shorten the URL, my boss feel relieved, and he asked whether the old long link still accessible or not. I said, yes. He panicked!

What must I do, first, you need to add canonical to your site tag. The canonical will contains the long link. Second, if you must, you need to put a redirection whenever someone is trying to access the long link to the correct short link.

Using this, well, your SEO is getting better and not screwed up a lot. I hope this is useful to you all folks! Please feel free to comment 🙂

Orchard – Slow?


Hello! I’m back!

Lately there was an issue related to a site that I have published. It was using Orchard 1.4.1 and it is (the client think) is slow. I am confused for the first when I face the issue. “It is running so fast in my computer!”, I said. But then it was a client and of course, they didn’t accept such reason.

Then I began to browse for the solutions and I got some as described below.

  1. Maintain the server performance (IIS) on this Orchard documentation, I found that some steps may be taken. Managing App Pool Recycle can be useful too. 🙂
  2. Updating your Orchard. This discussion clearly describe that updating orchard can make the site runs faster.
  3. I reference back to the first link. Removing the unused modules. I was using Disqus for the website’s comment system. What I got is a complaint from the client for their web is so slow. I can’t blame them for the slow connection. Disqus load outside files and data. Then I try to calm them down using normal comment from Orchard and it runs a bit faster. Well, not quite a good decision for I have to implement some more functions so that the Orchard.Comments will act like Disqus. Fool indeed.

That’s the three maintenance that I have done. I think the site runs quite faster now. I hope they like it.

Details


I run into something a very unpleasant experience with my girlfriend. We fight because of something. From that I got an idea to post. So let me share.

What a detail means to you? Is something detailed is bad or not necessary? Do you love something abstract or placed by a well named variable? Well, everything is depend on your view. But for me, details are important and something too detailed is not necessary but have to be placed. What was that means?!

Details are important because through it you can understand thing more. Like when you are coding your programs, you need to place the comments at least in every method declaration so that anyone who will continue your code will easily understand what that method means. But if you put all the comments in every line, people will think “Did the previous programmer thinks that we don’t know that this means a loop?!” Too detailed is not necessary. It will just make the reader feel tired with all your details. But it has to be placed. Where? In the document of course!

See? Detailed things are needed. In coding, in giving direction, in writing a novel, in reporting, in many things! But can you imagine if you have all the details of one forum’s database while you are just a normal user? Must be very bad if it is happened. You may use it for something bad or just feel “Uuggh! Other person must have the same data and knows who I am!” Bad eh?

So people, do things in detail. Because tiny details is the art of great complexity. I would like to quote a writing that I saw in Chiang Mai.

In every simplicity you see, there is a great complexity behind it.

Develop: Generic or Specific


Sorry for a long time not blogging. I was doing some activities that I can not delay. This article is about developing application. I compare in developing generic application or specific application.

My mom had just bought an Android tablet and she wanted to use it as her tool in teaching. My mom is a biology teacher. Then she asked me to install biology stuffs inside. I went to a place named Google Play and looked for those apps. What I got is a really big disappointment. Most of them are not filling my mom’s criteria. I asked some friends on twitter whether they have ever know any apps like that, and no one answers. I deduct that they don’t know so they are afraid to answer.

Well, that is a specific application. One need an application that can do this and that but focus on a single topic. In this case, it is biology. Because I couldn’t find any app, so I told my mom I will build her the app. When I want to build, some questions come to me.

  1. Should I build it only to my mom’s tablet or to every teacher to ease them in teaching?
  2. Should I give freedom for my mom to add an extra lesson or info in her teaching or give her just what she needs now?

Well, the first question is quite easy to answer. But the second one is hard. If I build the application and allows my mom to create new lesson, chapters, sub chapters, and details in that lesson, will it helps her or not. I choose to interview and she thinks that it is a great idea! So I think this is a generic application. It is an application to ease teacher to teach, by putting the topics in their tablet. Any teacher can use this application. But still it is a specific application. It is focused in teaching. What makes it generic is that if one day I want to create an application that the main function is to present something, well, I can use my classes and just modify a little.

Generic and specific, two things that are different, but can not be separated. Another example of generic application is that stock management. You can use the same classes in stock management application to create library books management, storage management, and anything! Think generic, because in this world, any idea you have, you are not the first one to think about it.

Instant or Step-by-Step


Hello! It is me again! I want to discuss about two ways in learning here. My approach is learning in software/web development. In software/web development, the developer have to write their code using text editor or IDE. If they are using text editor, then the code must be interpreted and compiled using different software (not the text editor itself). But if they are using IDE, it will just a button click ahead to build things. Then, what I say instant development learning is learning using the IDE (even for the first time) and step-by-step learning is using the text editor first, then IDE after gaining much knowledge.

This writing is made because I once learn using the step-by-step technique and I met someone (let’s just say that someone is a she) using the instant technique. She is older than me and I can say, she produce more than me. But one day, she met a failure in her application and she gets confused because her IDE just do all task. I just simply don’t want everyone to feel the same experience, that’s why I write this post.

Okay, let’s start the discussion. IDE is a powerful tools. Can detect error, can fix error, can do anything that the text editor mostly can’t do. Text editor is just a tool where you can write the code and that’s all. Text editor that I use is EditPlus. It is quite powerful because it has a feature that most text editor don’t have, template. Now, IDE is giving simplicity to coder so they don’t have to think about any details so much. While in text editor, they do not even recognize the other class (if you are using object oriented programming) that you have made in the other file. But as I said before, because IDE is giving everyone (newbie or expert or even guru) so much feature to ease the work, it will spoil those newbies and make them lazy to understand about what really happen when they type something.

For example, I choose NetBeans IDE. NetBeans have a feature in JavaME to let the user build an application using visualization. Don’t expect EditPlus to do so. But then later on, a newbie come and build an application using the visual. Mostly they will just drag and drop and finish. When other people look on their code, mostly they say, “What is this? I can’t understand it clearly!” While there’s another newbie that using the text editor. He can write as he want, put comments as he want, and let the compiler tell him about the warnings, errors, and he fix it by himself. Also, he only write codes that he needs and what he thinks the other may need (like comments). Then other people look on their code and say, “You write efficiently, great!” I don’t put a bad mark on NetBeans, but newbies that using it mostly do the same mistake, bad dirty codes. Then because of the knowledge of writing good and efficient code, the newbie that use text editor before can use the IDE much more efficient later on. While the other newbie is busy in disturbing the other to help him understand.

What I want to say is, IDE is created to ease people in building their application, not to ease people in learning how to develop application. So, while we are learning, why don’t we use the simple one, understand and use the more complex one in far more efficient way?