crm9
crm9

Reputation: 11

How to make links homepage only vs. site-wide on tumblr

I've been looking everywhere for code that would allow me to make the banner ads on my site show on the homepage only. Right now they show up site-wide and the advertisers are asking me to change it. I've unsuccessfully tried looking up the right code, but so far it has proven impossible. I'm only coming up for fixes for Blogger and Wordpress, and I need something for tumblr.

Any help would be much appreciated.

Thanks!

Upvotes: 1

Views: 941

Answers (2)

Vladimir Starkov
Vladimir Starkov

Reputation: 19803

  1. Output certain div only on homepage? — No.
  2. Show certain div only on homepage? — Yes, with css snippet.

How to output certain div only on homepage?

Tumblr has only two main types of page:

  • PermalinkPage
  • IndexPage

IndexPage include 3 sub-types:

  • TagPage
  • DayPage
  • SearchPage

Tumblr has no else statement for if blocks, that's why it is impossible to output banner ads only on home page — it would be outputted on other index pages.

How to show certain div only on homepage?

You can hide #banner ads with css using this tip:

Step 1. In your Tumblr markup to your html change your body tag to this snippet:

<body class="
    {block:IndexPage}  index-page  {/block:IndexPage}
    {block:TagPage}    tag-page    {/block:TagPage}
    {block:DayPage}    day-page    {/block:DayPage}
    {block:SearchPage} search-page {/block:SearchPage}
">

Step 2. Then make sure you output #banner only for index pages:

{block:IndexPage} <div id="banner">...</div> {/block:IndexPage}

Step 3. After that you will have four classes for control demonstration(show/hide) of your #banner div, this css snippet must be added to Custom CSS field on customize page:

.index-page #banner {
    /* not neccessable, only for tip's logic demonstration */
    display: block;
}

.tag-page #banner,
.day-page #banner,
.search-page #banner {
    /* hide on all index pages except home index-page */
    display: none;
}

Notice: this tip only hide div, not non-output.

I posted screeenshots of Edit HTML button and Custom CSS field to show the simplicity of the second method and to cheer you up.
edit html buttoncustom css field

Upvotes: 1

zlog
zlog

Reputation: 3316

Could you use javascript to only should the page on the homepage?

Upvotes: 0

Related Questions