I want all meta descriptions and meta keywords in one file - meta-tags

I have multiple pages with different meta keywords and meta descriptions.
I want the meta description and meta keyword to be compiled in one file and i need a code which can retrieve the specific meta data form the list to each page. I want to keep different meta keywords and meta description to different pages, but just want all of them in one single file.
Which means, once the code is run, all pages, should be able to get their respective meta tags from this list. Hope i am clear.
I had tried to work down as below:
Meta tags in the file:
$meta['keywords'] = "Keyoword, more words, ...";
$mtea['description'] = "...";
<?php include('header.php'); ?>
<?php include('footer.php'); ?>
Defining in index.php
<meta name="keywords" content="<?php echo $meta['keywords']; ?>" />
<meta name="description" content="<?php echo $mtea['description']; ?>" />
But this didnt work.
Any help on this is appreciated.

Related

Retrieve relative urls from a text

I have a string of HTML with both absolute and relative URLs and I'm trying to retrieve only the relative URLs. I tried using the get-urls package but this only retrieves absolute URLs.
An example of the string of html received.
<!DOCTYPE>
<html>
<head>
<title>Our first HTML page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<h2>Welcome to the web site: this is a heading inside of the heading tags.</h2>
<p>This is a paragraph of text inside the paragraph HTML tags. We can just keep writing ...
</p>
<h3>Now we have an image:</h3>
<div><img src="/images/plantTracing.gif" alt="Graphic of a Mouse Pad"></div>
<h3>
This is another heading inside of another set of headings tags; this time the tag is an 'h3' instead of an 'h2' , that means it is a less important heading.
</h3>
<h4>Yet another heading - right after this we have an HTML list:</h4>
<ol>
<li>First item in the list</li>
<li> Second item in the list</li>
<li>Third item in the list</li>
</ol>
<p>You will notice in the above HTML list, the HTML automatically creates the numbers in the list.</p>
<h3>About the list tags</h3>
</body>
</html>
Currently doing this
getUrls(string of HTML received)
It only returns {https://github.com/}
I want to return {https://github.com/, /modules/example.md}
The get-urls package requires the URL to either start with a scheme such as http:// or to start with a known top-level domain.
In fact, the doc even contains this Require URLs to have a scheme or leading www. to be considered an URL.
Since you're looking for relative paths that have neither of those, that package will not do what you want.
You will probably benefit best from an actual HTML parser such as cheerio which find the HTML attribute based URLs based on HTML context, not on just text matching tricks as that will find all the paths that are relative URLs.

Google Custom Search results includes html with “nocontent” tag

Our site have Google Custom Search set up. Instructions from Google have been followed, including downloading the CSE.xml file and adding “a new attribute enable_nocontent_tag="true" to the CustomSearchEngine tag”. The rest of the CSE file is left to default. The Search engine keywords field have been left empty. The “nocontent” class have been added to the menu and the underlying menu items which exists on all pages. The page have been running with the “nocontent” class on the menu for 2 weeks.
The problem is that if the searchterm occurs in the menu it will then appear in the results.
This is an example of our menu html:
<header class="nocontent page-head">
<nav class="main-nav-section">
<ul>
<li class="nocontent">
###
</li>
</ul>
</nav>
</header>
When we go to Google Search Console under the menu item “Crawl” and use Fetch as Google, then the html comes up as expected with the “nocontent” class on the menu.
This is our cse.xml file:
<?xml version="1.0" encoding="UTF-8" ?>
<CustomSearchEngine id="###" creator="###" language="da" encoding="UTF-8" enable_suggest="true" enable_nocontent_tag="true">
<Title>###</Title>
<Description>###</Description>
<Context>
<BackgroundLabels>
<Label name="_cse_hinwieyku6m" mode="FILTER" />
<Label name="_cse_exclude_hinwieyku6m" mode="ELIMINATE" />
</BackgroundLabels>
</Context>
<LookAndFeel nonprofit="false" element_layout="1" theme="7" custom_theme="true" text_font="Arial, sans-serif" url_length="full" element_branding="show" enable_cse_thumbnail="true" promotion_url_length="full" ads_layout="1">
<Logo />
<Colors url="#008000" background="#FFFFFF" border="#FFFFFF" title="#0000CC" text="#000000" visited="#0000CC" title_hover="#0000CC" title_active="#0000CC" />
<Promotions title_color="#0000CC" title_visited_color="#0000CC" url_color="#008000" background_color="#FFFFFF" border_color="#336699" snippet_color="#000000" title_hover_color="#0000CC" title_active_color="#0000CC" />
<SearchControls input_border_color="#D9D9D9" button_border_color="#666666" button_background_color="#CECECE" tab_border_color="#E9E9E9" tab_background_color="#E9E9E9" tab_selected_border_color="#FF9900" tab_selected_background_color="#FFFFFF" />
<Results border_color="#FFFFFF" border_hover_color="#FFFFFF" background_color="#FFFFFF" background_hover_color="#FFFFFF" ads_background_color="#fff7f5" ads_border_color="#FFFFFF" />
</LookAndFeel>
<AdSense />
<EnterpriseAccount />
<ImageSearchSettings enable="false" />
<autocomplete_settings />
<sort_by_keys label="Relevance" key="" />
<sort_by_keys label="Date" key="date" />
<cse_advance_settings enable_speech="true" />
</CustomSearchEngine>
Note: I'm assuming that your question is the following statement:
The problem is that if the searchterm occurs in the menu it will then appear in the results.
I think you might be misinterpreting the purpose of the nocontent class. The documentation says:
When Google Custom Search sees this tag, we'll ignore any keywords it contains and won't take them into account when calculating ranking for your Custom Search engine.
At the end of that document is also the following section:
Using nocontent won't impact your site's performance in Google Web Search, or our crawling of your site, in any way. We'll continue to follow any links in tagged content; we just won't use keywords to calculate ranking for your Custom Search engine.
So, the purpose of nocontent is not to prevent the included content from appearing in your CSE results but just to prevent any keywords in the included content from influencing the ranking of the results.
You can find some more discussion on this topic in the Google Custom Search support forums, for example in this thread.
P.S. There is a different product, the Google Search Appliance, which does support excluding content from indexing via googleoff/googleon tags.

Kentico meta data information

Using a Head HTML code webpart, i'm adding OG meta data:
<meta property="og:title" content="{% CurrentDocument.DocumentName #%}" />
<meta property="og:type" content="article" />
<meta property="og:url" content="{% CurrentDocument.AbsoluteURL #%}" />
<meta property="og:description" content="{% StripTags(CurrentDocument.Summary) #%}" />
How would i then change the current title and standard description tag?
On your parent page for example /blog set the page title and description under Properties>Metadata using a macro. Then on the sub-pages let it automatically inherit that content. Take a look at this macro for the page description:
{% if(CurrentDocument.ClassName == "cms.blogpost"){BlogPostSummary}else{"Kentico MVP Brenden Kehren talks about Kentico how tos, provides code samples and education and just life in general."} #%}
What's happening here is the macro is checking the current page's class and if it's a blog post, then it uses the BlogPostSummary field and sets the description using that, otherwise if it's a blog or blog month, it uses the other text.
There should be no need to manually set those on each page unless you really have crazy SEO requirements. Even if so, you can create fields in your page type for those and still dynamically set them vs. manually set each one under metadata.
Are you looking for changing title and description HTML tags by a web part or just configuring it for some page?
If you just want to configure title and description of the HTML page then you can just select the document in the Pages application and then go to Properties -> Metadata. Documentation for that is here
If you are looking to somehow change the title and description by a web part then you would actually need to develop a custom web part and access the current page title of the page in code behind. Something like this works.
Even using the selected item transformation, transformatted item is a page from your content tree and as such has the Properties -> Metadata section. Moreover, titles and descriptions are inherited by default so you can just change or odd macros to their parent and it changes the title and description for pages in your selected transformation.

Google Plus not reading from meta tags

Below are the meta tags I am using for Google plus
<html itemscope itemtype="http://schema.org/Watch Movies Online">
<meta itemprop="name" content="Watch Movies"/>
<meta itemprop="description" content="Watch Movies Online">
<meta itemprop="image" content="https://www22.verizon.com/images/biglogo.gif" />
I see them in view source of the page. when I actually click G+ button, it is not reading the values from here. Not able to figure out what I am missing.. Pls suggest me...
The itemtype that you've specified does not appear to be a valid one. Please note that you can only use types specified by schema.org. Please change the type to a valid one and try again.
Apart from that, it would be good if you can specify the URL of your site where it's not working. Furthermore, you can use the Google Rich Snippets testing tool to test your site. This might help tracking down the problem you're having.
You have to add the following snippet at the top of the document or add to your definition:
<html itemscope itemtype="http://schema.org/**yourschematypegoeshere**">
Where you replace "yourschematypegoeshere" with one of these, http://schema.org/docs/full.html.

debugger info & issues

complete HTML virgin 3 weeks ago but have managed to stumble along and get my site up and running to an ok standard but im having problems with fb intergration, fb like looks like it should, comments posting as they should but on debug i get the following....
Scrape Information
Response Code 200
Fetched URL http://shropshireradio.com/
Canonical URL http://ShropshireRadio.com/
Object Properties
fb:app_id 149188391870835
og:url http://ShropshireRadio.com/
og:type website
og:title Streaming Shropshire DJs
og:image
og:description music of all genres under 1 roof
og:updated_time 1331952439
Raw Open Graph Document Information
Meta Tag <meta property="fb:app_id" content="149188391870835" />
Meta Tag <meta property="og:type" content="website" />
Meta Tag <meta property="og:url" content="http://ShropshireRadio.com" />
Meta Tag <meta property="og:title" content="Streaming Shropshire DJs" />
Meta Tag <meta property="og:description" content="music of all genres under 1 roof" />
Meta Tag <meta property="og:image" content="http://i1067.photobucket.com/albums/u437/ShropshireRadio/ShropshireRadio.jpg" />
Redirect Path
original http://shropshireradio.com/
og:url http://ShropshireRadio.com/
Final URL is in bold (this is the URL we tried to extract metadata from).
I can see above that it doesnt look right but cant match it up to my code to see whats wrong!! any help appreciated!! Cheers
I've had to change 2 urls fetched and cononical to post this in my script it is correct
The content attribute for the meta tag with property "og:type" should be something from this list currently you have it as the url for your site.
the prefix attribute of your head tag should be this
og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# website: http://ogp.me/ns/website#
also, you should change the data-href attribute of your fb:like tag from http://www.facebook.com/ShropshireRadio.comTeam to http://shropshireradio.com/

Resources