Repeating Content - PHP includes? [SEO] - php

I have quite large amount of the same content that needs to be repeated on all 28 product pages of a website that I am working on.
In terms of SEO, I know web sites like Google don't like this and just see this as duplicated content.
I thought using a <?php include 'page.php' ?> would resolve this but this just writes the text as HTML and therefore makes no impact meaning it would still be seen as duplicated content.
I know I can use <META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW"> so that bots don't read these pages but if I was to do this, the only page it would be following is the homepage.
What would be the best way to get around this?
Is it possible to use the NOFOLLOW method for certain sections of the website?
Any suggestions on this would be very helpful!

My suggestion would be to think about your visitors first, not Google and their SEO requirements. Is the repetition of content beneficial to the visitors, then do it.
In SEO terms: if you duplicated content 28 times it might be seen as the same content, so it's not counted seperately. So what? It IS the same content, and you know it.
Websites are made for visitors in the first place, and search engines secondly. You should take SEO optimization in consideration, but don't let it dictate the user experience of your website. Make the best website you can, for real people.

Google understands boilerplate content, so if you need the information on the pages, then so be it.
Google is generally quite good at recognizing "boilerplate text" (text
which you repeat on many pages) and treating it appropriately. I
wouldn't worry about having to place a disclaimer on your pages. If
you want to make it clearer to search engines that it's not relevant
to your content, you could also just place the text in an image
(personally, I'd just place the text on the pages normally).
https://www.seroundtable.com/google-duplicate-text-14515.html

There's a better way to do this.
Combine the 28 product pages into 1 page that serves dynamic content from a database.
So each time you go to this single page, you pass a particular product ID (through a query string parameter, form data, a cookie, or a SESSION variable).
So instead of:
product_bicycle.php
product_skateboard.php
product_widget.php
etc.
You could have:
products.php?id=123
products.php?id=234
products.php?id=345
etc.
If all your product information in stored in raw HTML files, you'd just have to put those into a MySQL database. Create a table called products. Put in it a column called something like "Product_ID" which would hold the values like "123", "234", and "345" shown above. And put in another column like "Product_Details" which would hold the HTML of the product description.
When the page loads, you'd want PHP to do the following things:
Show the HTML for the page header, logo, navigation tabs, and other shared items. (Use the PHP "echo" or "print" statement - or just include it in the raw HTML of the page.)
Use the $_GET, $_POST, $_COOKIE, or $_REQUEST variables to get the product ID passed to the page. For example, "$id = $_GET['id'];"
Do a SQL query to pull up the product record based on the ID.
Show the description of the product from the result set.

Related

Php - URL structure to link specific comment

Context: I am building the blog section of a website in Symfony2.
Question:
Which is the best way to link a specific comment in a news? How should I define the route structure?
Examples:
Single News Url:
example.com/news/{news_id}
Single News + Comment Url:
example.com/news/{news_id}/comment/{comment_id}
or
example.com/news/{news_id}#comment-{comment_id}
or
example.com/news/{news_id}?comment={comment_id}
These are just some suggestions...
VERY IMPORTANT:
I need to use both the news_id and the comment_id inside a controller. They need to be retrievable/available.
Structure of the suggested links will have different outcomes, and your comment_id variable wont be available for your script in all cases.
Something important for news page they affect SEO differently.
first 2 variants of the url.
example.com/news/{news_id}/comment/{comment_id}
example.com/news/{news_id}?comment={comment_id}
commment_id WILL be available in your script. Symfony will pass to your controller or you will be able to get it from the Request object (or from $_GET variable - but don't do this)
browser WILL NOT
don't worry you WON'T have duplicate content if you don't create both routes for the same page.
from SEO point of view you are creating a separate page for each comment (I know you are not), that's the way what google would except from that url structure. To avoid duplicate content just add canonical link element to HEAD to point to the root url <link rel="canonical" href="example.com/news/{news_id}" />
hashtag url variant
example.com/news/{news_id}#comment-{comment_id}
comment_id WILL NOT be available in your script. Everything after # is handler directly by browser, and it WILL NOT send it to the server at all. The comment_id value WILL still be available by javascript (this is how stackoverflow does it)
browser WILL try to move(scroll) to a portion of the html, where the Key after # is used as ID.. eg. <div id="comment_id-123">. If you don't have element with the ID in your markup, it will stay on top.
solution
Based on assumption that you don't want separate page for each comment, and you only need the comment_id for pagination of the comments.
Right solution would be to use the # variant of URL.
load the page with just the news_id
after page load, do an ajax call with the comment_id parameter for comments, or for 1st page if there is no parameter.
change the comment section with returned information about pages etc.
add loader images, there so user will know whats happening as this increases UX.
more SEO suitable alternative
If you want better SEO, more suitable url would be not with ids but with slugs, and also without unnecessary words. I personally suggest this:
example.com/n/{news_slug}#{comment_title_slug}-{comment_id}
// would become something like1
example.com/n/answer-to-life-is-awesome#yeah-it-was-a-great-book-5435335435
If you can handle the parsing, and db querying, it could be also without the /n prefix.
You mixed two different concepts:
Links
The two following links carry the same parameters, news and comment ids:
example.com/news/{news_id}/comment/{comment_id}
or
example.com/news/{news_id}?comment={comment_id}
A browser opening these URLs will not scroll the page.
Links with anchor
This following link have only one parameter, news id, and it uses an anchor:
example.com/news/{news_id}#comment-{comment_id}
A browser opening this URL will scroll to the anchor.
So it depends of your need, if you want that the visitors' browsers scroll to the comment, use an anchor (it's also possible with Javascript).
Here are valid anchors:
<div id="comment-42">...</div>
or
<p>...</p>
Here is a link leading to this answer: https://stackoverflow.com/questions/33176341/php-url-structure-to-link-specific-comment/33179630#33179630
See also #! URLs.
I believe the better way is using #comment-{comment_id} because the duplicate URLs problem that the other 2 URLs may cause.

How to pass parameters from a PHP file to the template?

I have a website made with WP (a customer passed me). He want to see in one of the pages, a list of product categories, and to get the list of this product categories, I have to send a request to an API in another website. The site will response with an XML that contain the categories. To make the request I will use some PHP library. After the response is arrived, I want to show those categories in the page of my site of my customer.
I have followed the first answer here to call a php file before rendering a template, but imagine that I want to pass a variable (product categories) from the php to to the template. How can I do that?
You will probably want to cache the results of the XML that comes back to you (unless it is truely dynamic), and possibly store it in a table. You can decide how often you need to refresh the cache. (This will protect your site and their API from DOS attacks, or even just high volume).
Once you have your data stored in a table, your template can simply retrieve it.
This pattern will reduce the coupling between the two parts of your solution, and make things a bit easier to build / debug.

For Google crawling purposes: Single PHP pull-page, or individual pages for each different item?

I am creating a site and want to have individual pages for each row in a database table. The information on each page is fairly useful and comprehensive, and it would be really nice if Google could index them.
My initial thought was to just create a single PHP template page and pull the correct information for whatever the user is looking at, but my fear is that search engines won't be able to index all of the pages.
My second thought was to batch-create/automate the process of creating the individual pages as html files (for the 2000+ rows in the table), because then I would be guaranteed that they'd be crawled. However, if I ever needed to make a change to the design, I'd have to re-process them all. Kind of a pain...
My final consideration was to just pick a page in my site and list all of the possible php pages in a hidden div, but I wasn't sure if search engines can index from that. I assume they just pull from the HTML, so it'd be able to find it, right?
Any suggestions? I would love it if I can just create a single page that populates based on what they user clicks, but I want them to be indexed.
Search engines can index dynamic pages so using one PHP file to create thousands of unique product pages will be fine for SEO. After all, each page/product will have a unique URL and will be seen as a unique page as a result. All you need to do is link to your product pages within your website and/or submit an XML sitemap so you can be sure they are found and indexed.
By linking your pages, I literally mean link to your product pages. Search engines find new content primarily through following links. So if you want your product pages to be found you need to link to them. Using form based search is not a good way to do it as search engines generally don't play to well with forms. But there are lots of way to make links to your pages including HTML sitemaps and product category pages which then can link to products in that category. Really, any way yo u an get a link to your product pages is a good way to help ensure they are found by the search engines.
You don't have to post links on invisible DIV!
Just create the page and have parameterized content fetching.
You can include the pages in the XML sitemap and submit to Google or you can include your page urls in the HTML sitemap too.

Concept & Algorithm: How to record only single URL for widget?

I have created a widget for my web application. User's getting code and just pasting that code in their website and my widget works on their website something like twitter, digg and other social widgets.
My widget is on the basis of post, for a single post (say postid: 234) I am providing single widget, so anyone can embed the widget on their website.
Now I want to know that where all my widget is posted and for which post? for that I have recorded the URL of the site when my widget start (onload) but the problem arises when someone placed the widget in their blog or website's common sidebar. I am recording URL each time and hence if it's in sidebar of a blog then it's recording URL for every post which is creating duplicates.
can anyone help on this? How should I go so that I have only one single record for a widget on a site?
I think doing something like this is a bit tricky. Here are some ideas that pop to mind
You could for example ask the user to input their site's URL when they get the widget, or the widget could track the domain or subdomain, thus giving less URLs.
Just tracking the domain would obviously be problematic if the actual site is domain.com/sitename/, and there could be more than one site under the domain. In that case, you could attempt to detect the highest common directory. Something like this:
You have multiple URLs like this: domain.com/site/page1, domain.com/site/page2, and so on. Here the highest common directory would be domain.com/site.
I don't think that will always work correctly or provide completely accurate results. For accuracy, I think the best is to just ask the user for the URL when they download the code for the widget.
Edit: new idea - Just generate a unique ID for each user. This could be accomplished by simply taking the current timestamp or something, and hiding it into the code snippet the user is supposed to copy. This way you can track the ID itself and any URLs and domains it appears in can be grouped under it.
If you have an ID which doesn't get a hit in say week or something you could remove it from your database, and that way avoid filling it up with unused IDs.
I agree with Jani regarding a unique id. When you dish out the script you'll then be able to always relate back to that id. You are still going to have duplicates if the user uses the same id over and over, but at least you'll have a way of differentiating one user from another. Another useful advantage is that you are now able to, as Jani said, group by the ID and get a cumulative number for all of the instances where that user used the script & id.

How to Have Search Engines Index Database-Driven Content?

How can I make it so that content from a database is available to search engines, like google, for indexing?
Example:
Table in mysql has a field named 'Headline' which equals 'BMW M3 2005'.
My site name is 'MySite'
User enters 'BMW M3 2005 MySite' in google and the record will show up with results?
Google indexes web pages, so you will need to have a page for each of your records, this doesn't mean to say you need to create 1,000 HTML pages, but following my advice above will dynamically / easily provide a seemingly unique page for each product.
For example:
www.mydomain.com/buy/123/nice-bmw-m3-2005
You can use .htaccess to change this link to:
www.mydomain.com/product.php?id=123
Within this script you can dynamically create each page with up-to-date information by querying your database based on the product id in this case 123.
Your script will provide each record with it's own title ('Nice BMW M3 2005'), a nice friendly URL ('www.mydomain.com/buy/123/nice-bmw-m3-2006') and you can include the correct meta information too, as well as images, reviews etc etc.
Job done, and you don't have to create hundreds of static HTML pages.
For more information on .htaccess, check out this tutorial.
What ILMV is trying to explain is that you have to have HTML pages that Google and other search engines can 'crawl' in order for them to index your content.
Since your information is loading dynamically from a database, you will need to use a server-side language like PHP to dynamically load information from the database and then output that information to an HTML page.
You have any number of options for how to accomplish this specifically, ILMV's suggestion is one of the better ways though.
Basically what you need to do first is figure out how to pull the information from the database and then use PHP (or another server-side language) to output the information to an HTML page.
Then you will need to determine whether you want to use the uglier, default url style for php driven pages:
mysite.com/products.php?id=123
But this url is not very user or search engine friendly and will result in your content not being indexed very well.
Or you can use some sort of URL rewriting mechanism (mod_rewrite in a .htaccess file does this or you can look at more complex PHP oriented solutions like Zend Framework that provide what's called a Front Controller to handle mapping of all requests) to make it so that your url's look like:
mysite.com/products/123/nice-bmw-m3-2006
This is what ILMV is talking about with regard to url masking.
Using this method of dynamically loading content will allow you to develop a single page to load the information for a number of different products based on the Id thus making it seem to the various search engines as though you have a unique page for each product.

Categories