I am using the same CSS links and JavaScript scripts on numerous Web Forms ASPX pages on my website. So the head section of my pages are practically the same, bar a few exceptions.
I was told to look at Master Pages for Web Forms.
Is there somewhere I can store the duplicated scripts/links, and call them on each page, rather than placing the links in each head section?
yes you can use masterPage head protion where you have to place links only once and by binding pages to this master page links will get attached with all pages.If you want any other link other than this you can use content place holder in head portion and use that in the particular page
Related
I am developing a static website (don't need any server-side support. I have Basic HTML and JAVAscript) which have a number of pages.
all pages have the same top menu (header) and footer.
what is the best practice considering SEO?
I have two options :
Option 1. Should I copy header.html & footr.html code on every HTML page?
Option 2. Should I include header.html & footer.html on every HTML page?
which Option is better? Does any of them affect SEO?
if Option 2 is the right solution then my follow up question is "How to include common header.html and footer.html ?" I don't want to use PHP/ iframe.
For easy client end work , I could have suggested jquery or javascript for client end rendering of header and footer, but you are looking for SEO friendly web pages.
Considering SEO you need to have rendered HTML pages with header and footer so crawlers can read it (and above solution won't work for that as it renders extra stuff after page load). So either you go for copying and pasting header footer to each page or use PHP/.NET etc for server end rendering that will handle header and footer while rendering.
How often do you change the content of the header? When I was starting with web design I used to include the whole menu with/copy paste, and then do search/replace across all files. But this was before PHP and JS were around.
Content-wise, it should be the same. There could be a difference in the number of HTTP requests and load time if you are including something from another file.
These are so small speed differences that I don't think that it will make any difference SEO-wise.
I personally like to use PHP to include content but you have said that this is not an option for you. Depending on whether you want to use jquery, pure JS, or some other way there is a bunch of different approaches.
Using UI-Router the main page loads 2 other pages within them.
Index --> loads CSS and JS (including "application.js") with a <ui-view> to Navigation
Navigation page --> has navigation HTML with another <ui-view> to Content
Content
So basically Index > Navigation > Content
The Index is loading "application.js" with <script src="application.js"> at the bottom of the page. it contains all the page functionality.
It's loading successfully as I put an alert in the window.load function to make sure.... but what I'm finding is that I think the code in there is not reaching the other 2 embedded pages
The code works successfully if I put all the code and combine them together from the Index, Navigation, and Content into one single page. But not when separated but embedded together.
I tried putting:
<script src="~/assets/js/application.js"></script>
at the bottom of the Layout and Content but still didn't work..I'm guessing because technically it's loading as one page? but it's not really one page?...
HOWEVER if I copy and paste everything within application.js into the Layout and Content.. it WILL work.
That's such a crappy way of doing it though. How can I get this to work properly?
I have pages set up with razor code to use a consistent layout on every page.
I don't want the pages url to display with the .cshtml tag
How can I do this. I use JQuery, JavaScript, HTML, CSS, ASP.net (web Pages Logic)
EX URL; http:// www.site.com/page.htm
I am new to ASP and server side stuff.
#{
Layout = "~/Shared/_Layout1.cshtml"; <!--i use a _PageStart.cshtml that contains this line for dry purpose-->
Page.title = ""; #*add pages title here*#
}
<!--If you want to add Page specific stylesheets Link them here with HTML tags-->
#section ExtraHeadContent {
}
#section NavBarLinks {
<!--Enter links here for the top navigation bar <a class="topnav-link" href="~/index.html">| Home</a> -->
}
<!--Enter the Pages HTML content here. This will be displayed in the white content div-->
If there are any relevant pages or discussions you've found in the past please share.
The built in routing system within the ASP.NET Web Pages framework allows you to omit the file extension altogether. If you request www.yourdomain.com/YourPage (where YourPage represents a file called YourPage.cshtml), it should work by default. You can read more about it here: http://www.mikesdotnetting.com/Article/165/WebMatrix-URLs-UrlData-and-Routing-for-SEO.
As for replacing the file extension with .htm, I'm not sure that you hope to achieve by doing that. It won't improve SEO. However, one option would be to use a Nuget package called WebPageRouteHandler. I've written about that too: http://www.mikesdotnetting.com/Article/187/More-Flexible-Routing-For-ASP.NET-Web-Pages. Mapping each file individually could be a pain, but you could generate the routes dynamically from a database or from looping through the physical files to reduce the code required.
Morning,
I have an affiliate external widget i need to place on a page in wordpress.
The official code i have been given loads external content within this page.
<script type="text/javascript" src="http://www.convert.co.uk/widget/mobiles.js"></script>
where you place the line of code is where the external content is displayed.
This works perfectly on a non-wordpress site.
Once loaded the content uses some jquery effects and ajax to swap the results.
If i add this code within a wordpress page, it loads the content fine but the jquery within the external content does not work.
many thanks.
I do not have access the external code to change.
In the backend in the widget screen, drag and drop the text widget in the place where you need to display this external widget. Now, just add the code you have to that text widget and save it. You should now see your widget on the front end
Hope someone can help me on this. I manage an ASP.Net website and usually update script files and css files very often. I add current time appended into a single string as a query string parameter (eg: profileImage.jpg?123021) which makes the browser to look for the file without getting it from cache.
How can I do the same thing to all script tags and css links from the server side so that it loads the latest version of the file.
Any help appreciated.
Amila
If your asp.net website uses Master Pages, it should be easy to make these changes in the Master Page file. Look a file with the extension .master. If you are not sure how to make the specific edit, post the <head> area from the master page markup in a new question.
MSDN Master Pages: http://msdn.microsoft.com/en-us/library/wtxbf3hh(v=vs.100).aspx
If your site does not use master pages, then you'd need to create some server-side logic that affects the <head> section of the page. Below are some links to related QA's about injecting script and styles from the server side.
ASP.NET: How to (programmatically) attach a <script> tag, containing a link to .js, to <head>?
How to Add script codes before the </body> tag ASP.NET