Duplicate content on homepage of custom made PHP script - php

I coded a simple php blog. On the homepage it displays the most viewed post and also links to the actual page of the post similar to the frontpage of a wordpress blog for example.
How to avoid duplicate content for SEO purposes? Is there a certain html tag or code for search engines to prevent considering the post on homepage and the actual page duplicate??
Thanks

Homepage is the page that index.php or index.html outputs, even if this is a redirection to an inner file. If you want to make a cms for example with an admin panel and offer different templates, styles and plugins, and decide to divert the design code from the engine code, it is is functionally common sense that you 'll include the template in other template-folders (to keep the filesystem clean, well-organised, and easily accessible from the design work). In this way, admin panel will insert and update your site parameters to the database and the root index file will read those parameters from the db. So the best you have to do for SEO means is to create and keep well-informed all the xml files (sitemap, feed, rss, atom), include keywords (taxonomy),tags and metadata, coherence at internal and external links, keep a clean design output and a lot more parameters that needs a lot of space and time to analyze.

Related

How do I structure folders for users logged in and logged out?

I want the user's profile to show everything (logged in navbar, textbox they use to post their content on and all of their content) and then show their profile with a logged out navbar, selected content the user wants to show and no textbox to post content.
I am breaking up the html files (e.g. header, footer and main content) into separate php files. Is that a good idea if I want to implement the above said ?
I'm still developing on localhost but here's the current file structure which is a bit messy. I'm also trying to implement MVC but due to my lack of knowledge so far, it hasn't been done.
However you seem fit, but nice practice could be dividing up backend / frontend. Or have a public and a private directory as top layer, then go from there.
And yes, breaking up your files in header.php, *content.php and footer.php is smart for what you want. By doing this, you allow yourself to edit the main parts of you page independently, without having to update many html or php files. Just one file will do for every page.
Also google stuff like "common practice" for php structures.
Account for REST in your workflow How to create a RESTfull api
This Stackoverflow on html/php inlining is also usefull maybe.

loading a template in php

I'm building a small CMS in php but I have a problem with the front end. I have a folder name template inside the folder I got different themes
-admin
-template
---theme1
---theme2
---theme3
-index.php
when I load the index.php I can load the theme, but in the browser URL I get localhost/cms/template/theme1/page.php
but I like to have localhost/cms/page.php instead.
will you please tell me when I'm doing wrong!
Thanks.
I'm a little confused...you say this is a front end issue, but you point to the URL as the issue.
My guess is this: You need to identify different themes using separate stylesheets in CSS. Having different pages called page.php that looks differently definitely requires more work and complicates the issue. CSS was designed for you to customize the look of different pages and/or templates. Why not create 3 different stylesheets and then create a simple form that allows the administrator to choose which stylesheet to use (by radio button, or something else).
You can determine which stylesheet is "in use" in a number of ways - either on the back end or the front end. Given that this is a CMS, you'll probably want your administrators to choose the stylesheet and allow their selection to update a database entry or change a file on the back-end. No matter what you choose, you're URL's probably should not be affected.
Finally, you can rewrite URLs with .htaccess, but that can lead to more issues as you develop the site. Generally speaking - htaccess is overkill for issues like this.

ecommerce templates

I am currently working with a eCommerce site for a client but to keep things organized I am wanting to group some pages in sub folders. However, because of the nature of eCommerce it relies on several pages in its base folder (search.php, products.php, etc) to generate some of the pages of content and therefore I cannot really have any subfolders unless I make copies of all the necessary pages into each seperate subdirectory and then it makes everything more complicated not to mention creates issues of its own.
I hope my question is clear enough and I was wondering what options are in a situation such as this?
Is there a way I can setup a redirect page for each of these common pages inside the sub directory to redirect to the base files but maintain any POST data?
you can try store the filtered post values to session(preferred),cache,Database, or just include a php script into to the script in which you post the form data.

history.pushState navigation - what about meta tags - separate template?

i have been building a jquery navigation based site without reloads ( using PHP and AJAX ) and have recently come across the problem of page "back", "forward", and "reload" features as well as SEO friendliness.
--skip this section to get straight to question--
my site is currently (not using AJAX but ) loading a single index.php which has several "content" divs, one of which is visible (class="active") while the others are not displayed. When the user clicks a navigation link, a nice animation switches between content divs.
I have apache rewrites to map things like
http://mysite.com/about
to
http://mysite.com/index.php?page=about
where the "about" section would be the one thats displayed by default (while the other "content" divs are hidden). based on this parameter, i include the proper meta tags for the pages. my sitemap has mysite.com/about, mysite.com/blog so that they get indexed as nice separate pages.
However, I've recently decided to make this ajax-based since i plan to incorporate a lot more content and its stupid to load all content on one page.
Note: I'm also now implementing Smarty templates.
I decided to implement hash tags, but saw the inherent SEO problems, then i discovered hashbangs (wth?!) and then found the new HTML5 stuff with history.pushState() and History.js and have decided to use it.
so here comes the main question
if i have just one page which loads page templates in a content div with ajax, using history.pushState() to modify URL and using mod_rewrite and a PHP back-end that can serve a default content template in the case of a direct request like "mysite.com/about" (mysite.com/index.php?page=about) (for basic useabilty and SEO), i cannot also set meta content for direct requests unless i have two templates - a content template - and a meta template? is there another way around this?
are tags like <title> and <meta name="description"> important enough to warrant having a template especially for them?
in summary, i want my nice mod_rewrite URLS to pull up on google with the correct title and meta description for a particular ajax-loaded page content template.
EDIT
i'm going for pretty much the same thing they have going on here at hypem.com. they have an event listener which changes the <title> tag when new content is listed. they also serve the correct <meta name="description"> tag, but only if it is a direct request to one of the main pages, like blogs - other pages, like http://hypem.com/blog/indie+today/10332, return the meta tag for the main blog page, and only when directly requested
I would first build the site to work with all direct links and no ajax, and then add the ajax. However, only include the code that adds the ajax/history functionality if the page is being requested by a browser. If a web crawler hits your site, don't include the ajax/history functionality.

How do I make the Preview link on a WordPress post or page point somewhere else?

I've done a lot of small projects on the side lately where the client wants a good chunk of the website to stay the same, they just want to be able to edit particular "areas" of the site. Namely, some text in some box somewhere.
I've found that WordPress works for this pretty well. The interface is nice and friendly to use, and it's got lots of work behind it so I don't have to reinvent wheels, fix bugs, etc.
So what I wind up doing is making PHP pages which look like what the client wants, then making the content editable areas contain a particular post or page, which is what is editable in WordPress.
I'm having the particular page's contents displayed on the page using code like this
<?php echo apply_filters('the_content', $page_Contact->post_content); ?>
where $page_Contact is a variable defined elsewhere.
However, the "Preview" or "View Page"/"View Post" function on each page/post goes to the logical WordPress location and this is not the effect I want in this case.
So for example I have pages like this
www.site.com/index.php
www.site.com/about.php
www.site.com/contact.php
And so forth.
WordPress wants to have the "View Page" and "Preview Changes" links go places like
www.site.com/?page_id=2
www.site.com/?page_id=8&preview=true&preview_id=8&preview_nonce=45522671f5
Which is a problem because, in the permalink structure above, both of those go to the index.php page which, except for the page I'm using to structure index.php, it's not where I want the user/editor to go. And none of the cases above allow any sort of preview (which is a concession I'm willing to make given how I'm doing this)
Is there a way, preferably using a plugin to rig WordPress such that the preview for a page in the dashboard goes to a preview of the non-index.php page where the content will be housed? So for example the link for the "Contact" page in WordPress's dashboard goes to contact.php instead of ?page_id=2? This is a deal where I'm trying to get this done in the editing interface and I'm not concerned about the links in the site itself.
Obviously I would need to maintain this per-page and this would be a situation where new pages don't go up unless I put them there.
Take a look at the preview_post_link hook in WordPress -- it should be called when generating that link, and you can use that in conjunction with a custom field (or some logic) in order to construct whatever preview link you like.
Have you considered page links to plugin for wordpress? Also changing permalinks?

Categories