Blogger template - Inserting code with a specific URL.
I want to put specific meta-titles in a blogger blog. The meta-descriptions I put in the "description search" but the titles I want to manually put. I want it to be a different name than the title of the post.
I followed the instructions here to make the "if/else" conditions: https://support.google.com/blogger/answer/46995?hl=es
I got a code something like this:
<b:if cond='data:blog.pageType == "index"'>
**<title>Motivation</title>**
<b:elseif cond='data:blog.url == "http://www.xxxx1.com"'>
<title>Motivation2</title>
**<b:elseif cond='data:blog.url == "http://www.xxxx2.com"'>**
<title>Motivation3</title>
<b:else/>
<title>~~~~<data:blog.pageName/>~~ <data:blog.title/></title>
</b:if>
But this condition is not working
<b:elseif cond='data:blog.url == "http://www.xxxx1.com"'>
I tested with something like this:
<b:if cond='data:blog.url == "http://www.xxxx1.com"'>
<title>testing32</title>
</b:if>
and is not working either.
To prove that the data:blog.url is working I put a code like:
<b:if cond='data:blog.pageType == "index"'>
**<title><data:blog.url/></title>**
</b:if>
And it shows my URL perfectly....
The only way I found to make it work is by filter by the name of the post.
<b:else cond='data:blog.**pageName** == "motivation"'>
yes, is tedious but if the title has " ' " or " " " or extrange characters blogger not get the code right.
Each entry of your blog have an ID number. You have to use it in order to do a correct filter per post.
Then you can use basic conditional structures like this:
<b:if cond='data:blog.postId == "1234567890"'>
<title>Your custom title for post with ID 1234567890</title>
<b:else/>
<b:if cond='data:blog.postId == "0987654321"'>
<title>Your custom title for post with ID 0987654321</title>
</b:if>
<b:else/>
<!--Default title-->
<title><data:blog.pageTitle/></title>
</b:if>
You can get the postid editing each post and looking at the URL in the Blogger editor, or checking the source code of your post entry searching for "postid".
It's up to you but I would strongly suggest you to do those changes directly editing your posts and modifying manually the corresponding title tag.
Related
Normally, the title html in Blogger will appear like this:
<title><data:blog.pageTitle/></title>
If one prefers post title before blog title, you get two types of conflicting codes after google search:
First type:
<b:if cond='data:blog.pageType == "item"'>
<title>
<data:blog.pageName/></title>
<b:else/>
<title>
<data:blog.title/></title>
</title>
</b:if>
Second type:
<b:if cond='data:blog.pageType == "index"'>
<title>
<data:blog.title/></title>
<b:else/>
<title>
<data:blog.pageName/></title>
</b:if>
Which one is true?
What about the new tag <title><data:view.title.escaped/></title>
Otherwise, both of your code is true but the second code is preferred if you want to show post title instead of blog title on both item and static page types (static page like "About").
If you use first type title of item type return article title and for (static, archive, index, search, label) return the blog name.
If you use second type, the title index type (label, search and homepage) use your blog name and for (item, archive, static_page) use article title.
data:blog.pageName avaiable for item, static and archive, for item and static return article title and for archive page return date.
I get all the text I want from an HTML file when I use beautifulsoup like this:
category = soup.find_all("ol", {"class":"breadcrumb"})
catname = BeautifulSoup(str(category).strip()).get_text().encode("utf-8")
Output:
Home
Digital Goods
E-Books
BUT I want to skip the first category, i.e. 'Home'. I know that I can simply replace that word with "", but my question is really about how I get get beautifulsoup to get a very specific tag in the location I have singled out above.
The HTML code looks like this:
<ol class="breadcrumb">
<li>Home</li>
<li>Digital Goods</li>
<li>E-Books</li>
</ol>
Is there anything I can do to get the second and third 'li' tags from this 'breadcrumb' section, and not others in the file?
Example (which does not work but illustrates what I'm looking for):
category = soup.find_all("ol", {"class":"breadcrumb"}), find_all("li")[1:]
what about this:
category = soup.find("ol", {"class":"breadcrumb"}).findAll('li')[1:]
catname = BeautifulSoup(str(category).strip()).get_text().encode("utf-8")
?
My output is then:
[Digital Goods, E-Books]
In my blogger template I have the following code:
<b:if cond='data:blog.pageType == "index"'>
<!-- A lot of lines of code -->
</b:if>
<b:if cond='data:blog.pageType == "archive"'>
<!-- The same lines of code -->
</b:if>
It is possible to merge both 'if's in a unique expresión?. Something like using a simple logical OR?. I've tried the following with no result:
<b:if cond='data:blog.pageType == "index" ||
data:blog.pageType == "index"'>
<b:if cond='data:blog.pageType == "index" ||
data:blog.pageType == "index"'>
<b:if cond='data:blog.pageType == "index" OR
data:blog.pageType == "index"'>
<b:if cond='data:blog.pageType == "index" || "index"'>
<b:if cond='data:blog.pageType == "index" || "index"'>
Note: | is the HTML expression for '|'.
I google it with no result, and I also reviewed blogger b:if statement, but I found no answer to this simple question.
----- edited -----
The desired result is having a code like:
<b:if cond='data:blog.pageType == "index"' ||
cond='data:blog.pageType == "archive"'>
<!-- A lot of lines of code -->
</b:if>
In this way, I don't repeat the block 'lot of lines of code', resulting a more maintainable code, and simplier.
Anyway, knowing how to do a simple OR is a good thing to furure cases.
To simulate an OR operator in a blogger template, just use the IN operator.
In your case:
<b:if cond='data:blog.pageType in {"index","archive"}'>
<!-- This block is run only when the pageType is index or archive-->
</b:if>
The only way I found to accomplish this is transforming the OR to nested, negated ANDs.
In this case, 'data:blog.pageType' has only 4 valid values: item, static, index and archive. So, the following code do the trick:
<b:if cond='data:blog.pageType != "item"'>
<b:if cond='data:blog.pageType != "static"'>
<!-- This block is run only when the pageType is archive or index -->
<!-- A lot of lines of code -->
</b:if>
</b:if>
Edit: This works fine, but maybe you'll want to try the accepted answer given by Marcos.
EDIT: If you are going to give a downvote, at least explain why -.-
Also, read comments if my post is still unclear. I tried to explain it a bit more in the comments but if it is still unclear about what I'm saying, let me know and I will take printscreens and explain using images.
I have created a model like so
class Post(models.Model):
title_of_post = models.CharField(max_length=100)
actual_post = models.TextField()
and I put this model in the admin interface and enabled the admin interface. Now, when I go to 127.0.0.1/admin/ and sign in, I can add this model. The posts created in the Post model can be seen on the homepage (127.0.0.1) so say my "title_of_post" is "title" and my "actual_post" is "the actual post", if I go to 127.0.0.1 I can see both the title and actual post on the homepage. The problem is, when I am in the admin interface and in the actual_post text box / TextField section, suppose I write this.
Something.
else
It would not recognize that I pushed the enter key after the period. I tried
Something. <br>
else
but that also didn't work. It does not go on a new line after the period. Is there any way to go to the next line when inputting information from the text box / TextField in the django admin interface? Is there any way to put headers from the admin interface, not from the template? Essentially, I want to be able to create this html from the admin interface.
<h1>Something.</h1> <br>
else
in order to show html inside a property, you need to place like this in your template:
{{ post.actual_post|safe }}
the safe template filter its good for not escaping html tags inside your template.
And this will print as:
Something
else
intead of:
Something <br /> else
The site is: http://grantdeb.com
I want to be able to dynamically add meta properties to the Recommend(s) and Send(s). Right now, it's using the meta og: properties and that is totally NOT what I want.
The LIKE count is also showing incorrectly for each like even though I've pushed the data-href to it like:
<div class="fb-like" data-href="http://grantdeb.com/wedding-photographers-hampton-roads/[dynamic id]/Wedding-Photography" data-send="false" data-width="450" data-show-faces="false" data-action="recommend" ></div>
BUT - for some reason, once in a while the LIKE / SEND does NOT use the meta properties and correctly shows the correct count AND the correct picture / title I want for the Send.
If you go to our site at http://grantdeb.com look specifically at the "Jasmine Plantation Wedding Photography" (like the 5th post down) you'll see the number of Recommendations is correct, and if you hit the "Send" button at right bottom, it actually uses the correct title and picture we want.
That post is the way we want the Recommend / Send to display.
Why is that happening to some of them and to others it shows our og: metadata?
I can’t exactly see on your site what the problem is (or match your problem description with your site’s content) – but looking at the URL for the post you mentioned in Facebook debug tool, it seems that you have
<meta property="og:url" content="http://grantdeb.com" />
set for all of your detail pages – so that is what Facebook considers the “real” URL for all of your actual posts marked with this tag.
(Can’t tell if this is what you explicitly wanted or not, because your problem description is kinda fuzzy to me.)