Problems, need help? Have a tip or advice? Post it here.
14 posts Page 1 of 2
I am converting my static website to CouchCMS. My website url is 2nd result at google search for a particular keyword. I created a clonable template at index.php and posted number of posts. whenever i type www.mywebsiteurl.com an empty page appears. I know it can be fixed by placing blog_list.html in snippets folder. But I don't want to do it.

I want that whenever a user types www.mywebsiteurl.com, one of my blog posts should appear and not a html file from snippet folder. One of the user suggested that I should do a redirect to blog post with the following code.

Code: Select all
<!-- Do not allow anything other than page-view -->
<cms:if "<cms:not k_is_page />">
    <cms:redirect "<cms:link masterpage='index.php' page='some-blog-post-page-name' />" />
</cms:if>

<!-- Now we should be on page-view with all variables for a blog post available -->
<h1 id="blog_post_title"><cms:show k_page_title /></h1>


But the problem is if I redirect my homepage url to url of the post, home page url no longer exits. When a user types www.mywebsiteurl.com it gets redirected to www.mywebsiteurl.com/some-post-url.html. If I accept this method then there will be no content left at www.mywebsiteurl.com and I will loose the pagerank.

I want that the post should appear at homepage url (www.mywebsiteurl.com).

If only way to achieve this is by placing an html file in snippet folder then I want that if I do some changes to design of template at index.html, the changes should also reflect at html file in snippet folder. But then also there will always be inconvenience while updating the content of homepage by editing the file separately and not like any other post.

Please Suggest the best solution. Thank You in advance!
Since you are concerned about the SEO implications of your choice, please do keep in mind that by showing a blog post on the home page you'll actually have a case of 'duplicate content' (since the same content will also be accessible from the page-view URL). So, one of your URLs will be penalized by Google.

With that clear, you can try using <cms:masquerade> insted of <cms:redirect> in the code you quoted to make it -
Code: Select all
<!-- Do not allow anything other than page-view -->
<cms:if "<cms:not k_is_page />">
    <cms:masquerade "<cms:link masterpage='index.php' page='some-blog-post-page-name' />" />
</cms:if>

If your site has curl installed you should see that the home page now shows the blog post without redirecting.

In case it still redirects (as it will if curl is not available), then you can explicitly bring a blog post in context in the home page and show it by using cms:pages as follows -
Code: Select all
<cms:if k_is_page>
    .. existing code for showing single blog post ..
<cms:else />
    <cms:pages masterpage='index.php' page_name='some-blog-post-page-name' limit='1'>
        .. show this post ..
    </cms:pages>
</cms:if>

If you want to always show the latest post on the home page, use the following code instead -
Code: Select all
<cms:if k_is_page>
    .. existing code for showing single blog post ..
<cms:else />
    <cms:pages masterpage='index.php' limit='1'>
        .. show this post ..
    </cms:pages>
</cms:if>

You want any updates to the HTML markup in normal blog post to apply automatically to the home page, for that I suggest you move the portion of your code showing a single blog post into a snippet (say, named 'page.html'). Now we can use the same snippet for both views by amending the code above as follows -
Code: Select all
<cms:if k_is_page>
    <cms:embed 'page.html' />
<cms:else />
    <cms:pages masterpage='index.php' page_name='some-blog-post-page-name' limit='1'>
        <cms:embed 'page.html' />
    </cms:pages>
</cms:if>

Any changes you do to the snippet will now apply to both views.

Hope it helps.
Okay sir, I understand. I will keep the homepage html file in snippets folder to be safe from SEO perspective. But I want that if i do any changes to the design of template (index.html), it should also reflect on the homepage in snippets folder. Is there any way to achieve it? Otherwise if I have to change design, i need to edit 2 files - index.html and homepage. Thank you
I covered that in my last post - please take a look a the last point in it.
Sir the method you suggested at the end of your reply will also lead to duplicate content penalty by google. As homepage can also be accessed by pageview url. Is there a method by which no duplicate content is generated and editing of one template can apply changes to all posts and snippets. Thank you!
I want that the post should appear at homepage url (http://www.mywebsiteurl.com).

If you want to post appear exclusively on home page and do not let users access it in the blog, then while listing posts with cms:pages use negation as in http://docs.couchcms.com/tags-reference ... #page_name
Code: Select all
<cms:pages masterpage='blog.php' page_name='NOT my_first_entry, my_another_entry'></cms:pages>
Sir I am making my post appear on homepage url by using this code
Code: Select all
<cms:else/>
<cms:masquerade "<cms:link masterpage='index.php' page='raavi-font-typing-tutor' />" />
       
</cms:if>


I want the post can only be accesed by homepage url and not through post url becuase otherwise Google will penalize my website for duplicate content.

I didn't understand the solution you suggested in the reply. Please help. Thank you
dp121 wrote: I want the post be accesed not through post url

To achieve this, we have to cover 2 things:
1. skip listing it in all instances where you list blog posts.
2. if someone knowledgeable still types in the url, then redirect will help.

For the first goal to complete, find all instances where you show the list of posts via cms:pages and modify it according to my sample. For the second goal to complete - please think where you will send a visitor (and a bot), then use 'cms:redirect' tag.
Following is a simple sample with redirect to home page.
Code: Select all
<cms:if k_is_page = '1' && k_page_name = 'my-post' >
    <cms:redirect k_site_link />
</cms:if>
@trendoman, the OP has chosen cms:masquerade to display the inner page on home - I think the proposed redirection will affect the display on home page too.

I suppose using cms:pages to fetch the page would be the only choice left.
I'd also suggest that the inner page ('raavi-font-typing-tutor) be simply unpublished to practically remove it from everywhere else. The code on the homepage can explicitly ask for the unpublished page as show it as follows -
Code: Select all
<cms:if k_is_page>
    <cms:embed 'page.html' />
<cms:else />
    <cms:pages masterpage='index.php' page_name='raavi-font-typing-tutor' limit='1' show_unpublished='1'>
        <cms:embed 'page.html' />
    </cms:pages>
</cms:if>

What do you say?
inner page be simply unpublished to practically remove it from everywhere else.

@KK, elegant and simple solution :)
14 posts Page 1 of 2
cron