right so here we can see this is my blogger homepage and let's go to the dashboard and the first thing we will do is go.
Over here to theme and let's click on this arrow and click on edit html and let's go to the start of the body tag so i'll just press command f or control f and let's search for less than.
Body and here we will test our if conditionals now using if conditionals we can execute certain code based on some condition so for example if you.
Want to execute some code just for the home page we can use an if conditional so let me show you how to do that the first thing you have to do is type less than b and then type column if.
And then you have to add a condition so i'll just type c or nd for condition and then you have to type equals and then in single quotes or double quotes you can add the condition and here i'll.
Here will be executed based on the condition that we provide over here so i'll just show you a couple of examples of the conditions now for the first one i'll just add a condition.
Where it will be executed when we are on the home page so for that you have to type data colon viv dot is home page.
Now this is a condition that resolves to true if we are on the home page so here i'll just create a basic h1 tag and i'll just type hi welcome.
And let's close the h1 tag over here and let's save it and let's go back to our website and let's refresh this page and here we can see we have this text.
Displayed over here hi welcome so this is our home page and it is being displayed over here let's go to a post and let's see whether we have this text displayed so let's click on this third.
Post Wesdigital
And now here we can see when we are on a post we don't have the text displayed over here we only have the text displayed when we are on the home page.And if we go to any search page so let's click on search and i'll just search for let's say post and we can see this is the search page and we don't have the text displayed.
Over here as well so it is only displayed at the home page so that's basically how you use an if conditional in blogger let's take a look at some more examples so i'll just go to.
The start of the body tag and now for the condition i'll just add is post this condition will be satisfied.
Whenever we are on any post so let's save it and let's go back to our website and let's refresh this page and now we can see on the home page we.
Do not have the text displayed let's open a post and on the post we have the text displayed let's go back and let's open another post let's open the first post.
And here we can see even in the first post we have the text displayed so since we added the condition is post we have this text displayed on all the posts.
Let's see whether the text is displayed on a page so let's go back to the dashboard and let's go to pages and we don't have any pages let's create.
A new page i'll just type testing and here also i'll just start testing and let's click on publish and confirm.
Now let's open this page
And here we can see even in the page we don't have the text displayed we have the text display only when we are on a post.Now if you want to display this only on the page and not on a post then you have to go back to the if conditional so let's go back to the if conditional and here i'll just.
Tap is page and let's click on save now let's go back to our page and let's refresh this page and here we can see in the page we have.
The text displayed and let's go back to our post and let's refresh this page and now we can see in the post we don't have the text displayed now if you want to display the text in.
Both pages and posts then you have to go back to the if conditional and here you have to type data column view dot is single item.
And let's click on save now let's go back to our page and let's refresh this and we can see we have the text displayed let's go to our post and let's.
Refresh this page and here we can see we have the text displayed in both the post and the page now if you want to display this text only on a particular post or a page then.
You have to get the url of that post or page so let's display this only on the second post so let's go back to our home page.
Let's go to the second post and we want this text to be displayed only on this post right here so for that we have to copy this url and let's go back to our if conditional.
And here for the condition you have to type data column block dot url equals and here we will add double quotes and i'll just paste the link over here.
And now let's click on save now let's go back to our page and let's refresh this page and we have an error in our code so we need to have two equal sign.
So let's go back and let's fix that so here you have to type equals equals all right now let's click on save right now let's go back to our page and.
Let's refresh this page and now we can see we don't have the text displayed over here let's go to the second post and let's refresh this page and we can see we have the text.
Displayed over here let's go to the first post and let's see whether we have the text displayed and we don't have the text displayed let's go to the third.
Post and we don't have the text displayed so it is only displayed on the second post because we have added the if conditional now in the same way you can add.
Conditionals for different things so if you want to add conditional for all the archive pages then you can just change this to data column view dot is archive.
So this will include all the archives like the data archive the tags archive and so on and you can also add another conditional which is is search.
So this condition will be true when we are on a search page and if you want to have a conditional for the 404 page or the error page you can use is error.
So let's save it and let's go back to our website and let's refresh this page and we don't have anything displayed let's go to a random url.
And now we can see here we have the text displayed on the error page so this is how you can add if conditions in a blogger theme code now this can be useful for a lot of things in your.
Website like hiding and displaying a sidebar on specific pages or displaying a pop-up on a specific page or a specific type of content so in this way you can further customize your.
Blogger website alright so that's basically it for this video if you have any doubts you can ask in the comments below and if you like this video please click on the like button and subscribe.
To this channel to get the latest video updates thanks a lot for watching have a nice day you.