Typo3 Canonical URL in Plugin Pages - typo3

I have a typo3 Plugin (my own) which have lots of sub pages.
Now all Pages got their own canonical URL ... but I want that they only have the canonical from the page which contains the Plugin.
Is that possible?
Thanks in advance.

As far as the content changes with the parameters these parameters belong to the canonical URL.
You might not want your parameter specified pages indexed, but that needs other metatags than a non unique canonical url.
A canonical URL is used to have a unique URL for a page which can be accessed with multiple URLs. So Search engines know which URL to use and don't think of duplicate content.
If you really want to fool search engines with multiple content for the same URL you can of cause generate the base URL without all parameters and use it as canonical URL. Mind the value of config.linkVars. Just build your meta tag by hand using page.headerData.

Related

TYPO3 construct URL with several placeholders

I am not a developer but I need help talking to my web developer. We have a company website with staff profiles made with TYPO3. On each profile site, we want to embed an URL to a repository website, which will show a list of the person's publications. The URL encodes a SOLR search string for this repository. So, the URL is the same for all staff profiles except for a personal identifier somewhere in the middle. Instead of typing the complete URL into every staff profile page, I would prefer to have a URL constructed with placeholders like this
placeholderA+staffID+placeholderB
In case the SOLR search string changes in the future (i.e. excluding certain document types in this search or changing the sorting) we would have to change only the placeholders, not the complete URL in each and every profile page. There has to be a simple way to do this, but my web developer tells me this would require a database with the staff IDs and a lot of scripting. Is she right? Since we have to touch every profile page to include the URL initially, it would be ok to enter and store the unique staff identifier on each profile page. I just want to avoid touching each page again when changes are required.
It is such a useful concept, there has to be a plugin or something to do this already. Can you throw me some keywords or hints for our next discussion?
How is your URl build?
in general URLs are build in multiple parts
[[[<protocol>]<domain>]<path>[?<parameters>]][#<anchor>]
Now we need to identify where you want to insert the staffID:
is it in <path> or in <parameter>?
In TYPO3 we don't have a real <path>. It's just an image to hide the basic URL index.php with some parameters. first of all the parameter &id=123.
further parameter can occur as parameter or as path segments. Anyway TYPO3 will handle a translation between virtual path and parameters (either an extension like realurl or the core). For URL generation you call TYPO3 providing a list of parameters, or if a 'page' is called you will end with a list of parameters which will decide the rendering.
Then you can mixup the URL generation:
You take a generated URL and add path segments as you 'guess' them, without involving TYPO3. This might result in problems as you will call the server with an url TYPO3 does not know about as it has not generated it. If TYPO3 generates an URL it stores it in the database with the 'translation' into parameters.
realurl can guess the translation, but sometimes it failes, especially if chashes are used.
What are cHashes?
with cHashes TYPO3 secures the page cache against unrelated parameters. If a page is generated it depends on the parameters. Any further parameter might result in another page, so TYPO3 stores a hash of the parameters with each cached page. For verification this hash can be added to the URL. this additional parameter also is stored in the 'translation' table.
If you now add parameters to an URL which is stored and it gets translated back to parameters you have an cHash parameter which identifies the cached page. But only for a part of the parameters. your added parameters were not known and not considered when the page was generated and stored in cache. If the cached page is delivered your additional parameters are 'lost'.
So it is necessary to include all parameters in URL generation with TYPO3.
Your adding of the staffID must be done with TYPO3 and can't be an concatenation of path segments in the HTML templates (or javascript).
If you later on change your parameters you need to change the generation of your URLs.
I would recommend to add the staffID as a field to the record and generate the URL to the document list with TYPO3.

Facebook Like link to files

I don't find a way how to like link to a file ? Is it even possible ?
Example:
https://example.com/somefile.jpg/zip
And i would like to share that link to, so title description etc. is very desirable but I don't know where to put tags for og:url etc. since there are no meta tags at this.
That is not directly possible; we can of course not put HTML meta elements into jpeg or zip file.
But you can try and tackle this either of those two ways:
Share an HTML document instead, that returns the meta data, and triggers the actual file download via meta refresh or JavaScript. Or,
make your server return an HTML document instead of the file, only when the requesting User-Agent is the Facebook scraper.

tx_news direct link to news entry

it is possible to have a direct path to a special news entry?
example:
my link is: http://www.domain.de/start/topnewsdetail/news/really-long-name-of-news-entry.html
and it would be nice to have
http://www.domain.de/newsEntry.html.
Can someone give a hint?
it is a little bit complicated if you want a general automatic solution.
you can do it by hand if you insert pages of type 'external url' where you insert the long path as external url.
with realurl you have problems as realurl at least will use one path segment for the page with the detail view before the last segment which is for identifying the news record. AFAIK coolurl can ommit the path segemnt for the page.
on the other hand: make sure the news identification (title, subtitle?) is unique and does not collide with pathes for normal pages.
at last you can use .htaccess rewrites, but that needs to differentiate between short urls for news and short urls for top-level pages. So those urls will show the page, those urls are not generated inside of TYPO3 and so nowhere used (except manual)
this EXT. adds a custom link to records like system category or news:
https://typo3.org/extensions/repository/view/recordlink
It'S deployed for TYPO3 6.2 but perhabs it'S helpful to create an own EXT.?

Adding a URL hash into meta data for Facebook and Twitter share cards

I am looking to use a hash that is given in through a URL (www.example.com/index.html#myhash) and use it in the page's metadata that Facebook and Twitter can then retrieve to make a share card like this: https://dev.twitter.com/docs/cards/types/photo-card. Is this possible? Or would it be better to just use a PHP $_GET[] variable? I'm trying to keep the page static so the hash would be ideal, but I'm fairly sure I can't dynamically create the meta tag with JS because Twitter and Facebook will not execute that code. Thanks for help!
Correct, creating the meta elements client-side will not work because those crawlers don’t execute any client-side scripting code, they just look at the HTML code they get.
And the hash part of an URL is only of client-side importance, so it does not even get passed to the server when making an HTTP request – so generating those meta elements server-side based on the hash is also not possible.
And finally, changing the hash part of an URL does not make it a different URL – so this is not compatible with Facebook’s Open Graph philosophy, where the equation is one URL == one OG object.

How best to setup 301 redirects from an old site that has many duplicate entries indexed on Google?

I am currently working with a client to redevelop their website. One of the final things I need to do before launch, is to make sure that their old website's pages are correctly redirected to the new URL structure of the new website.
Unfortunately, when I check Google to see how their current site is indexed, this relatively small website appears to have over 1500 pages indexed.
When I look at the indexed links on Google, many appear to be duplicates of the same page, but because of the terrible URI structure used on the old website, Google treats them differently.
For example, the 'Map' page is indexed at least twice on Google, under the following 2 URLs:
www.website.com/frame_page-map.html?mp_session=iris7k85851j05q55piqci31u3&mp_session=iris7k85851j05q55piqci31u3?page_code=map&mp_session=iris7k85851j05q55piqci31u3&mp_session=iris7k85851j05q55piqci31u3
www.website.com/frame_page-map.html?mp_session=sel6m8j5cu8lulep4dqa32sne7&mp_session=sel6m8j5cu8lulep4dqa32sne7?page_code=map&mp_session=sel6m8j5cu8lulep4dqa32sne7&mp_session=sel6m8j5cu8lulep4dqa32sne7
Only the session name is different in the URL (and I have no idea why it is repeated four times in a single URL, either).
For reference, the replacement URL for this page is:
www.website.com/contact/map
My question is: How do I setup a redirect for these multiple records on Google? Do I simply set-up the redirect for the old URL minus all of the URI parameters (i.e. www.website.com/frame_page-map.html) or is there another better method to do this?
Thanks for any help you might be able to offer!
It depends on what your goals are. If you don't care about the querystrings then setup a 301 (permanent redirect) that points to just your root page - map.html. To prevent google from indexing querystring params as separate pages use the canonical tag and have it reference the parent. This isn't guaranteed to work, but google takes your canonical into consideration when indexing.
If you care about the querystring values then you will have to setup a redirect for each one. There is a querystring parameter that you can append to your redirects that will tell it to be ignored so you don't have to write a regex that detects it.